To: vim-dev@vim.org Subject: Patch 6.1.236 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.236 Problem: Memory leaks when appending lines for ":diffget" or ":diffput" and when reloading a changec buffer. Solution: Free a line after calling ml_append(). Files: src/diff.c, src/fileio.c *** ../vim61.235/src/diff.c Sun Oct 13 20:08:13 2002 --- src/diff.c Sun Oct 27 19:28:04 2002 *************** *** 1887,1894 **** if (nr > diffbuf[idx_from]->b_ml.ml_line_count) break; p = vim_strsave(ml_get_buf(diffbuf[idx_from], nr, FALSE)); ! ml_append(lnum + i - 1, p, 0, FALSE); ! ++added; } new_count = dp->df_count[idx_to] + added; dp->df_count[idx_to] = new_count; --- 1887,1898 ---- if (nr > diffbuf[idx_from]->b_ml.ml_line_count) break; p = vim_strsave(ml_get_buf(diffbuf[idx_from], nr, FALSE)); ! if (p != NULL) ! { ! ml_append(lnum + i - 1, p, 0, FALSE); ! vim_free(p); ! ++added; ! } } new_count = dp->df_count[idx_to] + added; dp->df_count[idx_to] = new_count; *** ../vim61.235/src/fileio.c Tue Oct 15 21:14:59 2002 --- src/fileio.c Sun Oct 27 18:58:11 2002 *************** *** 5238,5246 **** --- 5239,5249 ---- p = vim_strsave(ml_get_buf(frombuf, lnum, FALSE)); if (p == NULL || ml_append(lnum - 1, p, 0, FALSE) == FAIL) { + vim_free(p); retval = FAIL; break; } + vim_free(p); } /* Delete all the lines in "frombuf". */ *** ../vim61.235/src/version.c Sun Oct 27 14:40:49 2002 --- src/version.c Sun Oct 27 19:30:29 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 236, /**/ -- [clop clop] ARTHUR: Old woman! DENNIS: Man! ARTHUR: Man, sorry. What knight lives in that castle over there? DENNIS: I'm thirty seven. ARTHUR: What? DENNIS: I'm thirty seven -- I'm not old! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///