comparison src/change.c @ 29340:fba9e366ced4 v9.0.0013

patch 9.0.0013: reproducing memory access errors can be difficult Commit: https://github.com/vim/vim/commit/fa4873ccfc10e0f278dc46f39d00136fab059b19 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 30 22:13:59 2022 +0100 patch 9.0.0013: reproducing memory access errors can be difficult Problem: Reproducing memory access errors can be difficult. Solution: When testing, copy each line to allocated memory, so that valgrind can detect accessing memory before and/or after it. Fix uncovered problems.
author Bram Moolenaar <Bram@vim.org>
date Thu, 30 Jun 2022 23:15:03 +0200
parents a2710736125a
children 827d9f2b7a71
comparison
equal deleted inserted replaced
29339:a023e3008ae3 29340:fba9e366ced4
1533 { 1533 {
1534 if (p[0] == '/' && p[-1] == '*') 1534 if (p[0] == '/' && p[-1] == '*')
1535 { 1535 {
1536 // End of C comment, indent should line up 1536 // End of C comment, indent should line up
1537 // with the line containing the start of 1537 // with the line containing the start of
1538 // the comment 1538 // the comment.
1539 curwin->w_cursor.col = (colnr_T)(p - ptr); 1539 curwin->w_cursor.col = (colnr_T)(p - ptr);
1540 if ((pos = findmatch(NULL, NUL)) != NULL) 1540 if ((pos = findmatch(NULL, NUL)) != NULL)
1541 { 1541 {
1542 curwin->w_cursor.lnum = pos->lnum; 1542 curwin->w_cursor.lnum = pos->lnum;
1543 newindent = get_indent(); 1543 newindent = get_indent();
1544 break;
1544 } 1545 }
1546 // this may make "ptr" invalid, get it again
1547 ptr = ml_get(curwin->w_cursor.lnum);
1548 p = ptr + curwin->w_cursor.col;
1545 } 1549 }
1546 } 1550 }
1547 } 1551 }
1548 } 1552 }
1549 else // Not a comment line 1553 else // Not a comment line