patch 7.4.1755
Problem: When using getreg() on a non-existing register a NULL list is
returned. (Bjorn Linse)
Solution: Allocate an empty list. Add a test.
diff --git a/src/eval.c b/src/eval.c
index bd4a11a..28cc2f1 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -6051,7 +6051,7 @@
}
/*
- * Allocate an empty list for a return value.
+ * Allocate an empty list for a return value, with reference count set.
* Returns OK or FAIL.
*/
int
@@ -13173,7 +13173,9 @@
rettv->v_type = VAR_LIST;
rettv->vval.v_list = (list_T *)get_reg_contents(regname,
(arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
- if (rettv->vval.v_list != NULL)
+ if (rettv->vval.v_list == NULL)
+ rettv_list_alloc(rettv);
+ else
++rettv->vval.v_list->lv_refcount;
}
else