]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0074: Coverity warns for double free v9.0.0074
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Jul 2022 10:20:48 +0000 (11:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Jul 2022 10:20:48 +0000 (11:20 +0100)
Problem:    Coverity warns for double free.
Solution:   Reset cts_text_prop_count when freeing cts_text_props.

src/charset.c
src/structs.h
src/version.c

index 8c6ac1c2f49a5781c0459e987b7990662f60e987..f41248bd63e056b1fec3ccd0bb65fbd88ec8a05b 100644 (file)
@@ -964,7 +964,10 @@ 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
+    }
 #endif
 }
 
index 1d2aa0a8e28a69282cccd0ae18c3c7b2ed08b744..d5276724d8e3034822d2f7af9c6500fc1dce2a17 100644 (file)
@@ -4570,9 +4570,10 @@ typedef struct {
     char_u     *cts_line;          // start of the line
     char_u     *cts_ptr;           // current position in line
 #ifdef FEAT_PROP_POPUP
-    int                cts_text_prop_count;    // number of text props
-    textprop_T *cts_text_props;        // text props (allocated) or NULL
-    char       cts_has_prop_with_text;  // TRUE if if a property inserts text
+    int                cts_text_prop_count;    // number of text props; when zero
+                                       // cts_text_props is not used
+    textprop_T *cts_text_props;        // text props (allocated)
+    char       cts_has_prop_with_text; // TRUE if if a property inserts text
     int         cts_cur_text_width;     // width of current inserted text
 #endif
     int                cts_vcol;           // virtual column at current position
index 6d7aede80ca81cb1ef2a1385057e415e16f807a2..f7cbaf81bd3799486cb979bd4d89f4c3a428c311 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    74,
 /**/
     73,
 /**/