From a1e4f6a35c70cf265c77b445288f4e0ab6ffc19f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 26 Jan 2025 22:15:49 -0800 Subject: Avoid unlikely int overflow. * src/pgtkterm.c (pgtk_term_init): * src/xterm.c (x_term_init): Use a bool, not an int that keeps incrementing, to record whether initialization has occurred. --- src/xterm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/xterm.c') diff --git a/src/xterm.c b/src/xterm.c index 21968b38e78..00c61c486ed 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -30382,7 +30382,7 @@ static bool x_timeout_atimer_activated_flag; #endif /* USE_X_TOOLKIT */ -static int x_initialized; +static bool x_initialized; /* Test whether two display-name strings agree up to the dot that separates the screen number from the server number. */ @@ -30594,10 +30594,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) block_input (); + bool was_initialized = x_initialized; if (!x_initialized) { x_initialize (); - ++x_initialized; + x_initialized = true; } #if defined USE_X_TOOLKIT || defined USE_GTK @@ -30615,7 +30616,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) char **argv2 = argv; guint id; - if (x_initialized++ > 1) + if (was_initialized) { xg_display_open (SSDATA (display_name), &dpy); } -- cgit v1.2.1