summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclListObj.c1
-rw-r--r--tests/lseq.test6
2 files changed, 7 insertions, 0 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 0fd489c..6ca6a51 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -3274,6 +3274,7 @@ SetListFromAny(
if (elemPtrs[j] == NULL) {
return TCL_ERROR;
}
+ Tcl_IncrRefCount(elemPtrs[j]);
}
} else {
diff --git a/tests/lseq.test b/tests/lseq.test
index b8ae2e9..765d1e2 100644
--- a/tests/lseq.test
+++ b/tests/lseq.test
@@ -542,6 +542,12 @@ test lseq-4.9 {error case lrange} -body {
} -returnCodes 1 \
-result {index 7 is out of bounds 0 to 4}
+test lseq-convertToList {does not result in a memory error} {
+ trace add variable var1 write [list ::apply [list args {
+ error {this is an error}
+ } [namespace current]]]
+ list [catch {set var1 [lindex [lreplace [lseq 1 2] 1 1 hello] 0]} cres] $cres
+} {1 {can't set "var1": this is an error}}
# cleanup
::tcltest::cleanupTests