comparison src/vim9compile.c @ 20322:a3e78893a90b v8.2.0716

patch 8.2.0716: Vim9: another memory leak Commit: https://github.com/vim/vim/commit/5c2fe644430efabf9dadfb89a9f1e82367eaf28d Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 7 23:20:21 2020 +0200 patch 8.2.0716: Vim9: another memory leak Problem: Vim9: another memory leak. Solution: Clear typval when failing.
author Bram Moolenaar <Bram@vim.org>
date Thu, 07 May 2020 23:30:04 +0200
parents e501e32a892f
children 23188ef99fc2
comparison
equal deleted inserted replaced
20321:7ea995290692 20322:a3e78893a90b
4072 r = compile_load(arg, p, cctx, TRUE); 4072 r = compile_load(arg, p, cctx, TRUE);
4073 if (r == FAIL) 4073 if (r == FAIL)
4074 return FAIL; 4074 return FAIL;
4075 } 4075 }
4076 4076
4077 // Handle following "[]", ".member", etc.
4078 // Then deal with prefixed '-', '+' and '!', if not done already.
4077 if (compile_subscript(arg, cctx, &start_leader, end_leader, 4079 if (compile_subscript(arg, cctx, &start_leader, end_leader,
4078 bef1_tv, bef2_tv, new_tv) == FAIL) 4080 bef1_tv, bef2_tv, new_tv) == FAIL
4079 return FAIL; 4081 || compile_leader(cctx, start_leader, end_leader) == FAIL)
4080 4082 {
4081 // Now deal with prefixed '-', '+' and '!', if not done already. 4083 clear_tv(new_tv);
4082 return compile_leader(cctx, start_leader, end_leader); 4084 return FAIL;
4085 }
4086 return OK;
4083 } 4087 }
4084 4088
4085 /* 4089 /*
4086 * * number multiplication 4090 * * number multiplication
4087 * / number division 4091 * / number division
4185 4189
4186 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen])) 4190 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen]))
4187 { 4191 {
4188 char_u buf[3]; 4192 char_u buf[3];
4189 4193
4194 clear_tv(&tv1);
4190 vim_strncpy(buf, op, oplen); 4195 vim_strncpy(buf, op, oplen);
4191 semsg(_(e_white_both), buf); 4196 semsg(_(e_white_both), buf);
4192 return FAIL; 4197 return FAIL;
4193 } 4198 }
4194 4199
4195 *arg = skipwhite(op + oplen); 4200 *arg = skipwhite(op + oplen);
4196 if (may_get_next_line(op + oplen, arg, cctx) == FAIL) 4201 if (may_get_next_line(op + oplen, arg, cctx) == FAIL)
4202 {
4203 clear_tv(&tv1);
4197 return FAIL; 4204 return FAIL;
4205 }
4198 4206
4199 // get the second expression 4207 // get the second expression
4200 tv2.v_type = VAR_UNKNOWN; 4208 tv2.v_type = VAR_UNKNOWN;
4201 if (compile_expr6(arg, cctx, &tv1, &tv2) == FAIL) 4209 if (compile_expr6(arg, cctx, &tv1, &tv2) == FAIL)
4210 {
4211 clear_tv(&tv1);
4202 return FAIL; 4212 return FAIL;
4213 }
4203 4214
4204 if (*op == '+' && tv1.v_type == VAR_NUMBER && tv2.v_type == VAR_NUMBER) 4215 if (*op == '+' && tv1.v_type == VAR_NUMBER && tv2.v_type == VAR_NUMBER)
4205 { 4216 {
4206 // add constant numbers 4217 // add constant numbers
4207 tv1.vval.v_number = tv1.vval.v_number + tv2.vval.v_number; 4218 tv1.vval.v_number = tv1.vval.v_number + tv2.vval.v_number;