summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclCmdIL.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index f74368a..94ff2cc 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -2587,6 +2587,14 @@ Tcl_LpopObjCmd(
*/
if (objc == 2) {
+ if (!listLen) {
+ /* empty list, throw the same error as with index "end" */
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "index \"end\" out of range", -1));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX"
+ "OUTOFRANGE", NULL);
+ return TCL_ERROR;
+ }
elemPtr = elemPtrs[listLen - 1];
Tcl_IncrRefCount(elemPtr);
} else {