From b76dea45ad1f5edfce3d912f837877311368f132 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 5 Dec 2007 14:54:07 +0000 Subject: Prevent shimmering crash in [lsearch] when -exact and -integer/-real are mixed. [Bug 1844789] --- ChangeLog | 5 +++++ generic/tclCmdIL.c | 4 +++- tests/lsearch.test | 11 ++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3806b19..b07f345 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-12-05 Donal K. Fellows + + * generic/tclCmdIL.c (Tcl_LsearchObjCmd): Prevent shimmering crash + when -exact and -integer/-real are mixed. [Bug 1844789] + 2007-11-28 Jeff Hobbs * win/tclWinSock.c (Tcl_GetHostName): update to previous fix to diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 85e51d0..eae2d10 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -15,7 +15,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.47.2.11 2007/03/10 14:57:38 dkf Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.47.2.12 2007/12/05 14:54:08 dkf Exp $ */ #include "tclInt.h" @@ -3374,12 +3374,14 @@ Tcl_LsearchObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { return result; } + Tcl_ListObjGetElements(NULL, objv[objc - 2], &listc, &listv); break; case REAL: result = Tcl_GetDoubleFromObj(interp, patObj, &patDouble); if (result != TCL_OK) { return result; } + Tcl_ListObjGetElements(NULL, objv[objc - 2], &listc, &listv); break; } } else { diff --git a/tests/lsearch.test b/tests/lsearch.test index 86884c4..51d2176 100644 --- a/tests/lsearch.test +++ b/tests/lsearch.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: lsearch.test,v 1.10.2.3 2005/12/09 14:39:25 dkf Exp $ +# RCS: @(#) $Id: lsearch.test,v 1.10.2.4 2007/12/05 14:54:08 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -366,6 +366,15 @@ test lsearch-16.2 {lsearch -regexp allows internal backrefs} { lsearch -regexp {a aa b} {(.)\1} } 1 +test lsearch-21.1 {lsearch shimmering crash} { + set x 0 + lsearch -exact -integer $x $x +} 0 +test lsearch-21.2 {lsearch shimmering crash} { + set x 0.5 + lsearch -exact -real $x $x +} 0 + # cleanup catch {unset res} catch {unset increasingIntegers} -- cgit v0.12