aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-15 09:38:56 +0800
committerPo Lu2022-05-15 09:38:56 +0800
commit2a5e1d8c44e2a8b49135f5ed51f55cfe610ff5ce (patch)
treeff38b4fe29a814ee2e39b077b42f87b8bd80fcb3 /src
parent8e592973782e38be75faed39f557642bbae6aec5 (diff)
downloademacs-2a5e1d8c44e2a8b49135f5ed51f55cfe610ff5ce.tar.gz
emacs-2a5e1d8c44e2a8b49135f5ed51f55cfe610ff5ce.zip
Allocate some buffers used during event handling safely
* src/xterm.c (handle_one_xevent): Allocate string lookup and device disable data safely since they can potentially become very large.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/xterm.c b/src/xterm.c
index dbe07a85513..bb92e1bbe66 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -14536,6 +14536,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
14536 GdkEvent *copy = NULL; 14536 GdkEvent *copy = NULL;
14537 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display); 14537 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
14538#endif 14538#endif
14539 USE_SAFE_ALLOCA;
14539 14540
14540 *finish = X_EVENT_NORMAL; 14541 *finish = X_EVENT_NORMAL;
14541 14542
@@ -15753,7 +15754,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
15753 if (status_return == XBufferOverflow) 15754 if (status_return == XBufferOverflow)
15754 { 15755 {
15755 copy_bufsiz = nbytes + 1; 15756 copy_bufsiz = nbytes + 1;
15756 copy_bufptr = alloca (copy_bufsiz); 15757 copy_bufptr = SAFE_ALLOCA (copy_bufsiz);
15757 nbytes = XmbLookupString (FRAME_XIC (f), 15758 nbytes = XmbLookupString (FRAME_XIC (f),
15758 &xkey, (char *) copy_bufptr, 15759 &xkey, (char *) copy_bufptr,
15759 copy_bufsiz, &keysym, 15760 copy_bufsiz, &keysym,
@@ -18858,7 +18859,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18858 if (status_return == XBufferOverflow) 18859 if (status_return == XBufferOverflow)
18859 { 18860 {
18860 copy_bufsiz = nbytes + 1; 18861 copy_bufsiz = nbytes + 1;
18861 copy_bufptr = alloca (copy_bufsiz); 18862 copy_bufptr = SAFE_ALLOCA (copy_bufsiz);
18862 nbytes = XmbLookupString (FRAME_XIC (f), 18863 nbytes = XmbLookupString (FRAME_XIC (f),
18863 &xkey, (char *) copy_bufptr, 18864 &xkey, (char *) copy_bufptr,
18864 copy_bufsiz, &keysym, 18865 copy_bufsiz, &keysym,
@@ -18890,8 +18891,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18890 copy_bufsiz, &overflow); 18891 copy_bufsiz, &overflow);
18891 if (overflow) 18892 if (overflow)
18892 { 18893 {
18893 copy_bufptr = alloca ((copy_bufsiz += overflow) 18894 copy_bufptr = SAFE_ALLOCA ((copy_bufsiz += overflow)
18894 * sizeof *copy_bufptr); 18895 * sizeof *copy_bufptr);
18895 overflow = 0; 18896 overflow = 0;
18896 nbytes = XkbTranslateKeySym (dpyinfo->display, &sym, 18897 nbytes = XkbTranslateKeySym (dpyinfo->display, &sym,
18897 state & ~mods_rtrn, copy_bufptr, 18898 state & ~mods_rtrn, copy_bufptr,
@@ -19202,7 +19203,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19202 struct xi_touch_point_t *tem, *last; 19203 struct xi_touch_point_t *tem, *last;
19203#endif 19204#endif
19204 19205
19205 disabled = alloca (sizeof *disabled * hev->num_info); 19206 disabled = SAFE_ALLOCA (sizeof *disabled * hev->num_info);
19206 n_disabled = 0; 19207 n_disabled = 0;
19207 19208
19208 for (i = 0; i < hev->num_info; ++i) 19209 for (i = 0; i < hev->num_info; ++i)
@@ -20072,6 +20073,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20072 if (any && any != f) 20073 if (any && any != f)
20073 flush_dirty_back_buffer_on (any); 20074 flush_dirty_back_buffer_on (any);
20074#endif 20075#endif
20076
20077 SAFE_FREE ();
20075 return count; 20078 return count;
20076} 20079}
20077 20080