]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid unsafe alloca when looking up toplevels
authorPo Lu <luangruo@yahoo.com>
Sat, 14 May 2022 12:07:27 +0000 (20:07 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 14 May 2022 12:07:56 +0000 (20:07 +0800)
* src/xterm.c (x_dnd_compute_toplevels): Use SAFE_ALLOCA, since
alloca isn't safe when there are lots of toplevels or the window
manager is broken.

src/xterm.c

index 64c4f91a184b9a183e9113b0d25687d0bbed0206..c0d2ee40b0f6d1bf7507bfcf59a1d0188c17fd37 100644 (file)
@@ -2106,27 +2106,29 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo)
   toplevels = (Window *) data;
 
 #ifdef USE_XCB
+  USE_SAFE_ALLOCA;
+
   window_attribute_cookies
-    = alloca (sizeof *window_attribute_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *window_attribute_cookies * nitems);
   translate_coordinate_cookies
-    = alloca (sizeof *translate_coordinate_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *translate_coordinate_cookies * nitems);
   get_property_cookies
-    = alloca (sizeof *get_property_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *get_property_cookies * nitems);
   xm_property_cookies
-    = alloca (sizeof *xm_property_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *xm_property_cookies * nitems);
   extent_property_cookies
-    = alloca (sizeof *extent_property_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *extent_property_cookies * nitems);
   get_geometry_cookies
-    = alloca (sizeof *get_geometry_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *get_geometry_cookies * nitems);
 
 #ifdef HAVE_XCB_SHAPE
   bounding_rect_cookies
-    = alloca (sizeof *bounding_rect_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *bounding_rect_cookies * nitems);
 #endif
 
 #ifdef HAVE_XCB_SHAPE_INPUT_RECTS
   input_rect_cookies
-    = alloca (sizeof *input_rect_cookies * nitems);
+    = SAFE_ALLOCA (sizeof *input_rect_cookies * nitems);
 #endif
 
   for (i = 0; i < nitems; ++i)
@@ -2606,6 +2608,10 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo)
 #endif
     }
 
+#ifdef USE_XCB
+  SAFE_FREE ();
+#endif
+
   return 0;
 }