summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorFran├žois Revol <revol@free.fr>2020-05-05 18:25:39 +0200
committerVincent Sanders <vince@kyllikki.org>2020-05-05 20:14:51 +0100
commitad4cdc62b8cffd7d22b33623287a1679eb90c4b7 (patch)
tree1fc1201495a2bbfe2e4e192e397450bb880963f2 /desktop
parentd9a593c984b1e0d3f433d3271569d31d66569e18 (diff)
downloadnetsurf-ad4cdc62b8cffd7d22b33623287a1679eb90c4b7.tar.gz
netsurf-ad4cdc62b8cffd7d22b33623287a1679eb90c4b7.tar.bz2
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...
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index c04488063..6968bf21b 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -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;