From ad4cdc62b8cffd7d22b33623287a1679eb90c4b7 Mon Sep 17 00:00:00 2001 From: François Revol Date: Tue, 5 May 2020 18:25:39 +0200 Subject: 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... --- desktop/browser.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'desktop') 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; -- cgit v1.2.3