summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2008-01-22 11:38:31 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2008-01-22 11:38:31 (GMT)
commite8f77ac4b256a035643be895f8a3f8efbeae4081 (patch)
treed49bebfda586e207552bcff735bd73ccfe6458f6
parent7161eb819dfae3bb3413229cf70b6b47548cc2f9 (diff)
downloadtcl-e8f77ac4b256a035643be895f8a3f8efbeae4081.zip
tcl-e8f77ac4b256a035643be895f8a3f8efbeae4081.tar.gz
tcl-e8f77ac4b256a035643be895f8a3f8efbeae4081.tar.bz2
* generic/tclCmdIl.c (Tcl_LreverseObjCmd):
* tests/cmdIL.test (cmdIL-7.7): fix crash on reversing an empty list [Bug 1876793].
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclCmdIL.c11
-rw-r--r--tests/cmdIL.test5
3 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0542ff0..6382207 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-22 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclCmdIl.c (Tcl_LreverseObjCmd):
+ * tests/cmdIL.test (cmdIL-7.7): fix crash on reversing an empty
+ list [Bug 1876793].
+
2008-01-20 Jeff Hobbs <jeffh@ActiveState.com>
* unix/README: minor typo fixes [Bug 1853072]
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index dccfc10..18a4a72 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.135 2007/12/26 19:26:08 msofer Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.136 2008/01/22 11:38:33 msofer Exp $
*/
#include "tclInt.h"
@@ -2609,6 +2609,15 @@ Tcl_LreverseObjCmd(
return TCL_ERROR;
}
+ /*
+ * If the list is empty, just return it [Bug 1876793]
+ */
+
+ if (!elemc) {
+ Tcl_SetObjResult(interp, objv[1]);
+ return TCL_OK;
+ }
+
if (Tcl_IsShared(objv[1])) {
Tcl_Obj *resultObj, **dataArray;
List *listPtr;
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
index 0be7f19..7bddb26 100644
--- a/tests/cmdIL.test
+++ b/tests/cmdIL.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: cmdIL.test,v 1.36 2007/12/23 17:52:34 msofer Exp $
+# RCS: @(#) $Id: cmdIL.test,v 1.37 2008/01/22 11:38:34 msofer Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -750,6 +750,9 @@ test cmdIL-7.5 {lreverse command - unshared object} {
test cmdIL-7.6 {lreverse command - unshared object [Bug 1672585]} {
lreverse [set x {1 2 3}][unset x]
} {3 2 1}
+test cmdIL-7.7 {lreverse command - empty object [Bug 1876793]} {
+ lreverse [list]
+} {}
testConstraint testobj [llength [info commands testobj]]
test cmdIL-7.7 {lreverse command - shared intrep [Bug 1675044]} -setup {