From e8f77ac4b256a035643be895f8a3f8efbeae4081 Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Tue, 22 Jan 2008 11:38:31 +0000 Subject: * generic/tclCmdIl.c (Tcl_LreverseObjCmd): * tests/cmdIL.test (cmdIL-7.7): fix crash on reversing an empty list [Bug 1876793]. --- ChangeLog | 6 ++++++ generic/tclCmdIL.c | 11 ++++++++++- tests/cmdIL.test | 5 ++++- 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 + + * 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 * 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 { -- cgit v0.12