comparison src/search.c @ 13223:e37327129859 v8.0.1486

patch 8.0.1486: accessing invalid memory with "it" commit https://github.com/vim/vim/commit/82846a00ac0c135946c93c48c1657018a5c96b11 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 9 18:09:54 2018 +0100 patch 8.0.1486: accessing invalid memory with "it" Problem: Accessing invalid memory with "it". (Dominique Pelle) Solution: Avoid going over the end of the line. (Christian Brabandt, closes #2532)
author Christian Brabandt <cb@256bit.org>
date Fri, 09 Feb 2018 18:15:04 +0100
parents 891b821d3602
children 1961162121c7
comparison
equal deleted inserted replaced
13222:ee7ccac8928f 13223:e37327129859
682 /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */ 682 /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
683 else if (has_mbyte 683 else if (has_mbyte
684 && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count 684 && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
685 && pos->col < MAXCOL - 2) 685 && pos->col < MAXCOL - 2)
686 { 686 {
687 ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col; 687 ptr = ml_get_buf(buf, pos->lnum, FALSE);
688 if (*ptr == NUL) 688 if ((int)STRLEN(ptr) < pos->col)
689 start_char_len = 1; 689 start_char_len = 1;
690 else 690 else
691 start_char_len = (*mb_ptr2len)(ptr); 691 start_char_len = (*mb_ptr2len)(ptr + pos->col);
692 } 692 }
693 #endif 693 #endif
694 else 694 else
695 start_char_len = 1; 695 start_char_len = 1;
696 if (dir == FORWARD) 696 if (dir == FORWARD)