• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révisioncc4b36422ecb21a90aca78a06ba0d4bdf8dac3c7 (tree)
l'heure2022-07-02 23:15:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 9.0.0026: accessing freed memory with diff put

Commit: https://github.com/vim/vim/commit/c5274dd12224421f2430b30c53b881b9403d649e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 2 15:10:00 2022 +0100

patch 9.0.0026: accessing freed memory with diff put
Problem: Accessing freed memory with diff put.
Solution: Bail out when diff pointer is no longer valid.

Change Summary

Modification

diff -r d937ba61d344 -r cc4b36422ecb src/diff.c
--- a/src/diff.c Sat Jul 02 14:45:04 2022 +0200
+++ b/src/diff.c Sat Jul 02 16:15:03 2022 +0200
@@ -2643,6 +2643,20 @@
26432643 }
26442644
26452645 /*
2646+ * Return TRUE if "diff" appears in the list of diff blocks of the current tab.
2647+ */
2648+ static int
2649+valid_diff(diff_T *diff)
2650+{
2651+ diff_T *dp;
2652+
2653+ for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
2654+ if (dp == diff)
2655+ return TRUE;
2656+ return FALSE;
2657+}
2658+
2659+/*
26462660 * ":diffget"
26472661 * ":diffput"
26482662 */
@@ -2899,9 +2913,9 @@
28992913 }
29002914 }
29012915
2902- // Adjust marks. This will change the following entries!
29032916 if (added != 0)
29042917 {
2918+ // Adjust marks. This will change the following entries!
29052919 mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added);
29062920 if (curwin->w_cursor.lnum >= lnum)
29072921 {
@@ -2923,7 +2937,13 @@
29232937 #endif
29242938 vim_free(dfree);
29252939 }
2926- else
2940+
2941+ // mark_adjust() may have made "dp" invalid. We don't know where
2942+ // to continue then, bail out.
2943+ if (added != 0 && !valid_diff(dp))
2944+ break;
2945+
2946+ if (dfree == NULL)
29272947 // mark_adjust() may have changed the count in a wrong way
29282948 dp->df_count[idx_to] = new_count;
29292949
diff -r d937ba61d344 -r cc4b36422ecb src/version.c
--- a/src/version.c Sat Jul 02 14:45:04 2022 +0200
+++ b/src/version.c Sat Jul 02 16:15:03 2022 +0200
@@ -736,6 +736,8 @@
736736 static int included_patches[] =
737737 { /* Add new patch number below this line */
738738 /**/
739+ 26,
740+/**/
739741 25,
740742 /**/
741743 24,
Afficher sur ancien navigateur de dépôt.