desktop: clamp dpi in browser_set_dpi() to sensible values

The cocoa frontend missed a cast resulting in a huge negative dpi and
some GB allocated for thumbnails...
This commit is contained in:
François Revol 2020-05-05 18:25:39 +02:00 committed by Vincent Sanders
parent d9a593c984
commit ad4cdc62b8

View File

@ -23,12 +23,19 @@
*/
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "netsurf/browser.h"
#include "css/utils.h"
/* exported interface documented in netsurf/browser.h */
nserror browser_set_dpi(int dpi)
{
if (dpi < 72 || dpi > 250) {
int bad = dpi;
dpi = min(max(dpi, 72), 250);
NSLOG(netsurf, INFO, "Clamping invalid DPI %d to %d", bad, dpi);
}
nscss_screen_dpi = INTTOFIX(dpi);
return NSERROR_OK;