emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrong pointer comparison in w32fns.c


From: Juanma Barranquero
Subject: Wrong pointer comparison in w32fns.c
Date: Sun, 30 Oct 2022 00:36:20 +0200

Presumably, this is a bug in rarely used code (affecting NT 4 systems):

  CC       w32fns.o
w32fns.c: In function 'setup_w32_kbdhook':
w32fns.c:2738:24: warning: the comparison will always evaluate as 'true' for the address of 'newTitle' will never be NULL [-Waddress]
 2738 |           if (newTitle != NULL)
      |                        ^~
w32fns.c:2733:19: note: 'newTitle' declared here
 2733 |           wchar_t newTitle[64];
      |                   ^~~~~~~~

requiring something like this:

diff --git i/src/w32fns.c w/src/w32fns.c
index 5f652ae9e4..46c73f762a 100644
--- i/src/w32fns.c
+++ w/src/w32fns.c
@@ -2734,8 +2734,7 @@ setup_w32_kbdhook (void)
   int i;
 
   CoCreateGuid (&guid);
-  StringFromGUID2 (&guid, newTitle, 64);
-  if (newTitle != NULL)
+  if (StringFromGUID2 (&guid, newTitle, 64) && newTitle[0])
     {
       GetConsoleTitleW (oldTitle, 1024);
       SetConsoleTitleW (newTitle);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]