comparison src/ops.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 6cdf55afaae9
children 057c26b5c33a
comparison
equal deleted inserted replaced
29339:a023e3008ae3 29340:fba9e366ced4
1271 { 1271 {
1272 char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE); 1272 char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1273 1273
1274 netbeans_removed(curbuf, pos.lnum, bd.textcol, 1274 netbeans_removed(curbuf, pos.lnum, bd.textcol,
1275 (long)bd.textlen); 1275 (long)bd.textlen);
1276 // get the line again, it may have been flushed
1277 ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1276 netbeans_inserted(curbuf, pos.lnum, bd.textcol, 1278 netbeans_inserted(curbuf, pos.lnum, bd.textcol,
1277 &ptr[bd.textcol], bd.textlen); 1279 &ptr[bd.textcol], bd.textlen);
1278 } 1280 }
1279 #endif 1281 #endif
1280 } 1282 }
1320 while (pos.lnum < oap->end.lnum) 1322 while (pos.lnum < oap->end.lnum)
1321 { 1323 {
1322 ptr = ml_get_buf(curbuf, pos.lnum, FALSE); 1324 ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1323 count = (int)STRLEN(ptr) - pos.col; 1325 count = (int)STRLEN(ptr) - pos.col;
1324 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); 1326 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count);
1327 // get the line again, it may have been flushed
1328 ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1325 netbeans_inserted(curbuf, pos.lnum, pos.col, 1329 netbeans_inserted(curbuf, pos.lnum, pos.col,
1326 &ptr[pos.col], count); 1330 &ptr[pos.col], count);
1327 pos.col = 0; 1331 pos.col = 0;
1328 pos.lnum++; 1332 pos.lnum++;
1329 } 1333 }
1330 ptr = ml_get_buf(curbuf, pos.lnum, FALSE); 1334 ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1331 count = oap->end.col - pos.col + 1; 1335 count = oap->end.col - pos.col + 1;
1332 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count); 1336 netbeans_removed(curbuf, pos.lnum, pos.col, (long)count);
1337 // get the line again, it may have been flushed
1338 ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
1333 netbeans_inserted(curbuf, pos.lnum, pos.col, 1339 netbeans_inserted(curbuf, pos.lnum, pos.col,
1334 &ptr[pos.col], count); 1340 &ptr[pos.col], count);
1335 } 1341 }
1336 #endif 1342 #endif
1337 } 1343 }