]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0128: Coverity complains about possible double free v9.0.0128
authorBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 11:06:40 +0000 (12:06 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 11:06:40 +0000 (12:06 +0100)
Problem:    Coverity complains about possible double free.
Solution:   Clear the pointer to avoid warnings.

src/charset.c
src/version.c

index a8173c1246885e3e507e801cf86163ac8da541c7..2b657476df16a76109b3a26b37d13bcd146b5de4 100644 (file)
@@ -912,16 +912,13 @@ init_chartabsize_arg(
        char_u          *line,
        char_u          *ptr)
 {
+    CLEAR_POINTER(cts);
     cts->cts_win = wp;
     cts->cts_lnum = lnum;
     cts->cts_vcol = col;
     cts->cts_line = line;
     cts->cts_ptr = ptr;
 #ifdef FEAT_PROP_POPUP
-    cts->cts_text_prop_count = 0;
-    cts->cts_has_prop_with_text = FALSE;
-    cts->cts_cur_text_width = 0;
-    cts->cts_with_trailing = 0;
     if (lnum > 0)
     {
        char_u *prop_start;
@@ -951,7 +948,7 @@ init_chartabsize_arg(
                if (!cts->cts_has_prop_with_text)
                {
                    // won't use the text properties, free them
-                   vim_free(cts->cts_text_props);
+                   VIM_CLEAR(cts->cts_text_props);
                    cts->cts_text_prop_count = 0;
                }
            }
@@ -969,8 +966,8 @@ clear_chartabsize_arg(chartabsize_T *cts UNUSED)
 #ifdef FEAT_PROP_POPUP
     if (cts->cts_text_prop_count > 0)
     {
-       vim_free(cts->cts_text_props);
-       cts->cts_text_prop_count = 0;  // avoid double free
+       VIM_CLEAR(cts->cts_text_props);
+       cts->cts_text_prop_count = 0;
     }
 #endif
 }
index ac56f8c06ce1adfc02a2f6179fbf2cbb2324b67c..f079d3c7ecd5cc6da692b27778cf1fd09cec21ef 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    128,
 /**/
     127,
 /**/