]> granicus.if.org Git - vim/commitdiff
patch 8.2.4051: compiler complains about possibly uninitialized variable v8.2.4051
authorBram Moolenaar <Bram@vim.org>
Mon, 10 Jan 2022 11:26:33 +0000 (11:26 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 10 Jan 2022 11:26:33 +0000 (11:26 +0000)
Problem:    Compiler complains about possibly uninitialized variable.
Solution:   Add code to avoid a compiler warning. (John Marriott)

src/scriptfile.c
src/version.c

index c1ab41503fe877652ff52f02144e2da087f62bbb..7680fd505fa42f78febea80d9c37cb42abff4a49 100644 (file)
@@ -274,7 +274,7 @@ get_new_scriptitem(int *error)
 {
     static scid_T   last_current_SID = 0;
     int                    sid = ++last_current_SID;
-    scriptitem_T    *si;
+    scriptitem_T    *si = NULL;
 
     if (ga_grow(&script_items, (int)(sid - script_items.ga_len)) == FAIL)
     {
@@ -305,8 +305,10 @@ get_new_scriptitem(int *error)
 # endif
     }
 
-    // Used to check script variable index is still valid.
-    si->sn_script_seq = current_sctx.sc_seq;
+    // "si" can't be NULL, check only to avoid a compiler warning
+    if (si != NULL)
+       // Used to check script variable index is still valid.
+       si->sn_script_seq = current_sctx.sc_seq;
 
     return sid;
 }
index a2ce58e4b4a5b0dbe165ed0da98670dd3546f4f7..f3213eeabcc380516895e2c5349384ecc9d8eab7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4051,
 /**/
     4050,
 /**/