|
|
20b5ab |
diff --git a/src/vim9compile.c b/src/vim9compile.c
|
|
|
20b5ab |
index 535de05..ae7b253 100644
|
|
|
20b5ab |
--- a/src/vim9compile.c
|
|
|
20b5ab |
+++ b/src/vim9compile.c
|
|
|
20b5ab |
@@ -1073,21 +1073,26 @@ generate_PUSHF(cctx_T *cctx, float_T fnumber)
|
|
|
20b5ab |
|
|
|
20b5ab |
/*
|
|
|
20b5ab |
* Generate an ISN_PUSHS instruction.
|
|
|
20b5ab |
- * Consumes "str".
|
|
|
20b5ab |
+ * Consumes "*str". When freed *str is set to NULL, unless "str" is NULL.
|
|
|
20b5ab |
*/
|
|
|
20b5ab |
static int
|
|
|
20b5ab |
-generate_PUSHS(cctx_T *cctx, char_u *str)
|
|
|
20b5ab |
+generate_PUSHS(cctx_T *cctx, char_u **str)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
isn_T *isn;
|
|
|
20b5ab |
|
|
|
20b5ab |
if (cctx->ctx_skip == SKIP_YES)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
- vim_free(str);
|
|
|
20b5ab |
+ if (str != NULL)
|
|
|
20b5ab |
+ VIM_CLEAR(*str);
|
|
|
20b5ab |
return OK;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
if ((isn = generate_instr_type(cctx, ISN_PUSHS, &t_string)) == NULL)
|
|
|
20b5ab |
+ {
|
|
|
20b5ab |
+ if (str != NULL)
|
|
|
20b5ab |
+ VIM_CLEAR(*str);
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
- isn->isn_arg.string = str;
|
|
|
20b5ab |
+ }
|
|
|
20b5ab |
+ isn->isn_arg.string = str == NULL ? NULL : *str;
|
|
|
20b5ab |
|
|
|
20b5ab |
return OK;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
@@ -2547,7 +2552,7 @@ generate_tv_PUSH(cctx_T *cctx, typval_T *tv)
|
|
|
20b5ab |
tv->vval.v_blob = NULL;
|
|
|
20b5ab |
break;
|
|
|
20b5ab |
case VAR_STRING:
|
|
|
20b5ab |
- generate_PUSHS(cctx, tv->vval.v_string);
|
|
|
20b5ab |
+ generate_PUSHS(cctx, &tv->vval.v_string);
|
|
|
20b5ab |
tv->vval.v_string = NULL;
|
|
|
20b5ab |
break;
|
|
|
20b5ab |
default:
|
|
|
20b5ab |
@@ -3301,7 +3306,7 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
|
|
20b5ab |
key = get_literal_key(arg);
|
|
|
20b5ab |
if (key == NULL)
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
- if (generate_PUSHS(cctx, key) == FAIL)
|
|
|
20b5ab |
+ if (generate_PUSHS(cctx, &key) == FAIL)
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
|
|
|
20b5ab |
@@ -5978,7 +5983,7 @@ compile_assign_unlet(
|
|
|
20b5ab |
char_u *key_end = to_name_end(p + 1, TRUE);
|
|
|
20b5ab |
char_u *key = vim_strnsave(p + 1, key_end - p - 1);
|
|
|
20b5ab |
|
|
|
20b5ab |
- r = generate_PUSHS(cctx, key);
|
|
|
20b5ab |
+ r = generate_PUSHS(cctx, &key);
|
|
|
20b5ab |
}
|
|
|
20b5ab |
if (r == FAIL)
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
@@ -6149,7 +6154,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|
|
20b5ab |
// Push each line and the create the list.
|
|
|
20b5ab |
FOR_ALL_LIST_ITEMS(l, li)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
- generate_PUSHS(cctx, li->li_tv.vval.v_string);
|
|
|
20b5ab |
+ generate_PUSHS(cctx, &li->li_tv.vval.v_string);
|
|
|
20b5ab |
li->li_tv.vval.v_string = NULL;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
generate_NEWLIST(cctx, l->lv_len);
|
|
|
20b5ab |
@@ -7709,7 +7714,7 @@ compile_catch(char_u *arg, cctx_T *cctx UNUSED)
|
|
|
20b5ab |
p += len + 2 + dropped;
|
|
|
20b5ab |
if (pat == NULL)
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
- if (generate_PUSHS(cctx, pat) == FAIL)
|
|
|
20b5ab |
+ if (generate_PUSHS(cctx, &pat) == FAIL)
|
|
|
20b5ab |
return FAIL;
|
|
|
20b5ab |
|
|
|
20b5ab |
if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL)
|
|
|
20b5ab |
@@ -8080,7 +8085,9 @@ compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
if (p > start)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
- generate_PUSHS(cctx, vim_strnsave(start, p - start));
|
|
|
20b5ab |
+ char_u *val = vim_strnsave(start, p - start);
|
|
|
20b5ab |
+
|
|
|
20b5ab |
+ generate_PUSHS(cctx, &val;;
|
|
|
20b5ab |
++count;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
p += 2;
|
|
|
20b5ab |
@@ -8101,7 +8108,9 @@ compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
if (*skipwhite(start) != NUL)
|
|
|
20b5ab |
{
|
|
|
20b5ab |
- generate_PUSHS(cctx, vim_strsave(start));
|
|
|
20b5ab |
+ char_u *val = vim_strsave(start);
|
|
|
20b5ab |
+
|
|
|
20b5ab |
+ generate_PUSHS(cctx, &val;;
|
|
|
20b5ab |
++count;
|
|
|
20b5ab |
}
|
|
|
20b5ab |
break;
|