changeset 24510:b5786b4de9d1 v8.2.2795

patch 8.2.2795: Coverity warns for not using return value Commit: https://github.com/vim/vim/commit/169502fb0beb7eb21f72d6c4590483c069353b53 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 21 12:19:35 2021 +0200 patch 8.2.2795: Coverity warns for not using return value Problem: Coverity warns for not using return value. Solution: Check the return value of compiling the substitute expression.
author Bram Moolenaar <Bram@vim.org>
date Wed, 21 Apr 2021 12:30:04 +0200
parents faca76e8449d
children 2aaa71ea39fb
files src/version.c src/vim9compile.c
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2795,
+/**/
     2794,
 /**/
     2793,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6511,7 +6511,7 @@ compile_assignment(char_u *arg, exarg_T 
 		{
 		    // skip over the "=" and the expression
 		    p = skipwhite(op + oplen);
-		    compile_expr0(&p, cctx);
+		    (void)compile_expr0(&p, cctx);
 		}
 	    }
 	    else if (oplen > 0)
@@ -8525,6 +8525,7 @@ compile_substitute(char_u *arg, exarg_T 
 	{
 	    garray_T	save_ga = cctx->ctx_instr;
 	    char_u	*end;
+	    int		expr_res;
 	    int		trailing_error;
 	    int		instr_count;
 	    isn_T	*instr = NULL;
@@ -8538,13 +8539,14 @@ compile_substitute(char_u *arg, exarg_T 
 	    cctx->ctx_instr.ga_len = 0;
 	    cctx->ctx_instr.ga_maxlen = 0;
 	    cctx->ctx_instr.ga_data = NULL;
-	    compile_expr0(&cmd, cctx);
+	    expr_res = compile_expr0(&cmd, cctx);
 	    if (end[-1] == NUL)
 		end[-1] = delimiter;
 	    cmd = skipwhite(cmd);
 	    trailing_error = *cmd != delimiter && *cmd != NUL;
 
-	    if (trailing_error || ga_grow(&cctx->ctx_instr, 1) == FAIL)
+	    if (expr_res == FAIL || trailing_error
+				       || ga_grow(&cctx->ctx_instr, 1) == FAIL)
 	    {
 		if (trailing_error)
 		    semsg(_(e_trailing_arg), cmd);