To: vim_dev@googlegroups.com Subject: Patch 8.1.2178 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2178 Problem: Accessing uninitialized memory in test. Solution: Check if there was a match before using the match position. (Dominique Pelle, closes #5088) Files: src/search.c *** ../vim-8.1.2177/src/search.c 2019-10-18 20:53:30.693741624 +0200 --- src/search.c 2019-10-19 14:16:11.046674834 +0200 *************** *** 4877,4883 **** regmatch.startpos[0].col++; nmatched = vim_regexec_multi(®match, curwin, curbuf, pos.lnum, regmatch.startpos[0].col, NULL, NULL); ! if (!nmatched) break; } while (direction == FORWARD ? regmatch.startpos[0].col < pos.col : regmatch.startpos[0].col > pos.col); --- 4877,4883 ---- regmatch.startpos[0].col++; nmatched = vim_regexec_multi(®match, curwin, curbuf, pos.lnum, regmatch.startpos[0].col, NULL, NULL); ! if (nmatched != 0) break; } while (direction == FORWARD ? regmatch.startpos[0].col < pos.col : regmatch.startpos[0].col > pos.col); *************** *** 4887,4894 **** result = (nmatched != 0 && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum && regmatch.startpos[0].col == regmatch.endpos[0].col); ! /* one char width */ ! if (!result && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col) result = TRUE; } } --- 4887,4895 ---- result = (nmatched != 0 && regmatch.startpos[0].lnum == regmatch.endpos[0].lnum && regmatch.startpos[0].col == regmatch.endpos[0].col); ! // one char width ! if (!result && nmatched != 0 ! && inc(&pos) >= 0 && pos.col == regmatch.endpos[0].col) result = TRUE; } } *** ../vim-8.1.2177/src/version.c 2019-10-19 14:10:15.500046051 +0200 --- src/version.c 2019-10-19 14:17:18.278410749 +0200 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 2178, /**/ -- Computers make very fast, very accurate, mistakes. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///