comparison src/netbeans.c @ 17785:3f0fd418ac1d v8.1.1889

patch 8.1.1889: Coverity warns for using a NULL pointer commit https://github.com/vim/vim/commit/ea7ecfe2a08877f98edec9b9c26b9e1b3673f00b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 19 20:08:15 2019 +0200 patch 8.1.1889: Coverity warns for using a NULL pointer Problem: Coverity warns for using a NULL pointer. Solution: Use zero for column if pos is NULL.
author Bram Moolenaar <Bram@vim.org>
date Mon, 19 Aug 2019 20:15:04 +0200
parents ce04ebdf26b8
children 1848b3e07266
comparison
equal deleted inserted replaced
17784:0a3a42786ec8 17785:3f0fd418ac1d
1387 1387
1388 if (lnum == lnum_start 1388 if (lnum == lnum_start
1389 && ((pos != NULL && pos->col > 0) 1389 && ((pos != NULL && pos->col > 0)
1390 || (lnum == 1 && buf_was_empty))) 1390 || (lnum == 1 && buf_was_empty)))
1391 { 1391 {
1392 char_u *oldline = ml_get(lnum); 1392 char_u *oldline = ml_get(lnum);
1393 char_u *newline; 1393 char_u *newline;
1394 int col = pos == NULL ? 0 : pos->col;
1394 1395
1395 /* Insert halfway a line. */ 1396 /* Insert halfway a line. */
1396 newline = alloc(STRLEN(oldline) + len + 1); 1397 newline = alloc(STRLEN(oldline) + len + 1);
1397 if (newline != NULL) 1398 if (newline != NULL)
1398 { 1399 {
1399 mch_memmove(newline, oldline, (size_t)pos->col); 1400 mch_memmove(newline, oldline, (size_t)col);
1400 newline[pos->col] = NUL; 1401 newline[col] = NUL;
1401 STRCAT(newline, args); 1402 STRCAT(newline, args);
1402 STRCAT(newline, oldline + pos->col); 1403 STRCAT(newline, oldline + col);
1403 ml_replace(lnum, newline, FALSE); 1404 ml_replace(lnum, newline, FALSE);
1404 } 1405 }
1405 } 1406 }
1406 else 1407 else
1407 { 1408 {