From cf232785ce80073052aa5a13c154a4707343da30 Mon Sep 17 00:00:00 2001 From: ericm Date: Thu, 12 Oct 2000 21:14:33 +0000 Subject: * generic/tkConfig.c (Tk_InitOptions): Added Tcl_IncrRefCount/Tcl_DecrRefCount calls on valuePtr, to prevent memory leaks when the value object comes from the option database. [Bug: 6275]. --- ChangeLog | 7 +++++++ generic/tkConfig.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 95265f0..e85728e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-10-10 Eric Melski + + * generic/tkConfig.c (Tk_InitOptions): Added + Tcl_IncrRefCount/Tcl_DecrRefCount calls on valuePtr, to prevent + memory leaks when the value object comes from the option + database. [Bug: 6275]. + 2000-10-06 Jeff Hobbs * win/Makefile.in (cat32.${OBJEXT}): add win/ subdirectory to diff --git a/generic/tkConfig.c b/generic/tkConfig.c index dfdd237..338edb9 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkConfig.c,v 1.13 2000/10/01 21:31:36 ericm Exp $ + * RCS: @(#) $Id: tkConfig.c,v 1.14 2000/10/12 21:14:33 ericm Exp $ */ /* @@ -549,6 +549,13 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) continue; } + /* + * Bump the reference count on valuePtr, so that it is strongly + * referenced here, and will be properly free'd when finished, + * regardless of what DoObjConfig does. + */ + Tcl_IncrRefCount(valuePtr); + if (DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, (Tk_SavedOption *) NULL) != TCL_OK) { if (interp != NULL) { @@ -573,8 +580,10 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) } Tcl_AddErrorInfo(interp, msg); } + Tcl_DecrRefCount(valuePtr); return TCL_ERROR; } + Tcl_DecrRefCount(valuePtr); } return TCL_OK; } -- cgit v0.12