From 538c2afa4a7741c3a8a459feb9c27f13848b9e7b Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 18 Mar 2009 17:08:11 +0000 Subject: * win/tclWinFile.c (TclpObjNormalizePath): Corrected Tcl_Obj leak. Thanks to Joe Mistachkin for detection and patch. [Bug 2688184]. --- ChangeLog | 3 +++ win/tclWinFile.c | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d52c8e5..f8e4462 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-03-18 Don Porter + * win/tclWinFile.c (TclpObjNormalizePath): Corrected Tcl_Obj leak. + Thanks to Joe Mistachkin for detection and patch. [Bug 2688184]. + * generic/tclVar.c (TclLookupSimpleVar): Shift all calls to Tcl_SetErrorCode() out of TclLookupSimpleVar and onto its callers, where control with TCL_LEAVE_ERR_MSG flag is more easily handled. diff --git a/win/tclWinFile.c b/win/tclWinFile.c index bdbad41..46c8489 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -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: tclWinFile.c,v 1.97 2008/10/26 18:43:27 dkf Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.98 2009/03/18 17:08:11 dgp Exp $ */ /* #define _WIN32_WINNT 0x0500 */ @@ -2554,6 +2554,7 @@ TclpObjNormalizePath( char *lastValidPathEnd = NULL; Tcl_DString dsNorm; /* This will hold the normalized string. */ char *path, *currentPathEndPosition; + Tcl_Obj *temp = NULL; Tcl_DStringInit(&dsNorm); path = Tcl_GetString(pathPtr); @@ -2711,7 +2712,6 @@ TclpObjNormalizePath( * We're on WinNT (or 2000 or XP; something with an NT core). */ - Tcl_Obj *temp = NULL; int isDrive = 1; Tcl_DString ds; @@ -2983,6 +2983,16 @@ TclpObjNormalizePath( Tcl_DStringFree(&dsTemp); } Tcl_DStringFree(&dsNorm); + + /* + * This must be done after we are totally finished with 'path' as we are + * sharing the same underlying string. + */ + + if (temp != NULL) { + Tcl_DecrRefCount(temp); + } + return nextCheckpoint; } -- cgit v0.12