From a14dc8880490ddf17e78d3eacf6e892dd3dd6a67 Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Wed, 27 Sep 2006 13:49:05 +0000 Subject: * generic/tclFileName.c (TclGlob): added a panic for a call with TCL_GLOBMODE_TAILS and pathPrefix==NULL. This would cause a segfault, as found by coverity #26. --- ChangeLog | 6 ++++++ generic/tclFileName.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78a39c7..689e79a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-27 Miguel Sofer + + * generic/tclFileName.c (TclGlob): added a panic for a call with + TCL_GLOBMODE_TAILS and pathPrefix==NULL. This would cause a + segfault, as found by coverity #26. + 2006-09-26 Kevin Kenny * doc/Encoding.3: Added covariant 'const' qualifier for the diff --git a/generic/tclFileName.c b/generic/tclFileName.c index ec872d0..590c180 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFileName.c,v 1.75 2006/08/30 17:56:57 hobbs Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.76 2006/09/27 13:49:06 msofer Exp $ */ #include "tclInt.h" @@ -1894,12 +1894,17 @@ TclGlob( int objc, i; Tcl_Obj **objv; int prefixLen; + CONST char *pre; /* * If this length has never been set, set it here. */ - CONST char *pre = Tcl_GetStringFromObj(pathPrefix, &prefixLen); + if (pathPrefix == NULL) { + Tcl_Panic("Called TclGlob with TCL_GLOBMODE_TAILS and pathPrefix==NULL"); + } + + pre = Tcl_GetStringFromObj(pathPrefix, &prefixLen); if (prefixLen > 0 && (strchr(separators, pre[prefixLen-1]) == NULL)) { /* -- cgit v0.12