]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0478: potential deref of NULL pointer in fuzzy_match_str_with_pos v9.1.0478
authorglepnir <glephunter@gmail.com>
Wed, 12 Jun 2024 18:31:13 +0000 (20:31 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 12 Jun 2024 18:31:13 +0000 (20:31 +0200)
Problem:  potential deref of NULL pointer in fuzzy_match_str_with_pos()
          on cleanup (after v9.1.0476)
Solution: Only free the pointer if it is non-NULL (glepnir)

closes: #14973

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/search.c
src/version.c

index 864bfe3b801d195ebc317091df56ece5c6553d08..20bf399b20c1c9cac50c53adeadc978d6b48adc2 100644 (file)
@@ -5198,11 +5198,16 @@ fuzzy_match_str_with_pos(char_u *str UNUSED, char_u *pat UNUSED)
 
 cleanup:
     vim_free(tv_str.vval.v_string);
-    list_free(match_str_list);
-    list_free(match_pos_list);
-    list_free(match_score_list);
-    list_free(retlist);
-    list_free(l);
+    if (match_str_list != NULL)
+        list_free(match_str_list);
+    if (match_pos_list != NULL)
+        list_free(match_pos_list);
+    if (match_score_list != NULL)
+        list_free(match_score_list);
+    if (retlist != NULL)
+        list_free(retlist);
+    if (l != NULL)
+        list_free(l);
     ga_clear(match_positions);
     return NULL;
 #else
index cc2494521d77817009d09cd5c8fd3301100bd781..4b695c01e2bdc7e0da9a4a3475701fa123da18db 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    478,
 /**/
     477,
 /**/