From f46eaf609e1f9344671a7886f161d460edc0fe0c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 2 Mar 2026 17:03:17 +0200 Subject: [PATCH] ; * src/w32image.c (w32_gdip_export_frame): Add error checking. --- src/w32image.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/w32image.c b/src/w32image.c index 36d259a07c2..f0838fd0aba 100644 --- a/src/w32image.c +++ b/src/w32image.c @@ -580,9 +580,13 @@ w32_gdip_export_frame (HWND hwnd, Lisp_Object file, CLSID *clsid) made visible, in which case users might want them in the image. The downside is that the image has some of the desktop around the frame included in it. So what? */ - GetWindowRect (hwnd, &frame_rect); + if (!GetWindowRect (hwnd, &frame_rect)) + return -1; frame_width = frame_rect.right - frame_rect.left; frame_height = frame_rect.bottom - frame_rect.top; + if (!(frame_width > 0 && frame_height > 0)) + return -1; + hdc = GetWindowDC (hwnd); bits_per_pixel = GetDeviceCaps (hdc, BITSPIXEL); capture_hdc = CreateCompatibleDC (hdc);