]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0650: Vim aborts at startup when built with the example -O2 CFLAGS v9.2.0650
authorHirohito Higashi <h.east.727@gmail.com>
Mon, 15 Jun 2026 18:20:15 +0000 (18:20 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 15 Jun 2026 18:20:15 +0000 (18:20 +0000)
Problem:  Building with an optimizing example CFLAGS line in src/Makefile
          (which bypasses configure) aborts Vim at startup with a buffer
          overflow, because the compiler then defaults _FORTIFY_SOURCE to
          a level >= 2 (user202729)
Solution: Define FORTIFY_CFLAGS with -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
          and reference it from the optimizing example CFLAGS lines, the
          same pin configure already applies; at higher levels the check
          false-positives on the "x[1] but actually longer" struct-hack
          arrays.

fixes:  #20526
closes: #20530

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/Makefile
src/version.c

index 1a6fa1c66bb16f30e04288f3aba0ff76bf8f8bd5..f66d94f1aeddb0f34edbc9d7bdf1ea3b84e8d03d 100644 (file)
@@ -597,13 +597,19 @@ CClink = $(CC)
 #CFLAGS = -O -Olimit 2000
 #CFLAGS = -O -FOlimit,2000
 
+# Add $(FORTIFY_CFLAGS) to optimizing example lines below: at higher levels
+# (the compiler default with -O) the buffer overflow check aborts Vim on the
+# "x[1] but actually longer" struct-hack arrays (e.g. dictitem di_key).
+# configure adds this automatically; these examples bypass it.
+FORTIFY_CFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
+
 # Often used for GCC: mixed optimizing, lot of optimizing, debugging
-#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes
-#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wmissing-prototypes
+#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes $(FORTIFY_CFLAGS)
+#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wmissing-prototypes $(FORTIFY_CFLAGS)
 #CFLAGS = -g -Wall -Wmissing-prototypes
-#CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes
+#CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes $(FORTIFY_CFLAGS)
 #CFLAGS = -g -DDEBUG -Wall -Wshadow -Wmissing-prototypes
-#CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes
+#CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes $(FORTIFY_CFLAGS)
 
 # Use this with GCC to check for mistakes, unused arguments, etc.
 # Note: If you use -Wextra and get warnings in GTK code about function
index 392bae84c343ae5e8c08090e09ed551f7a41eee3..ff26c4350d4f1ce9f6b05582f2384d33e4b63067 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    650,
 /**/
     649,
 /**/