diff options
author | vincentdarley <vincentdarley> | 2003-10-23 10:07:09 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2003-10-23 10:07:09 (GMT) |
commit | 06f7470662af25ea53cefea3f2e731cbf6ce2eaf (patch) | |
tree | fb164689706be091d7b284d1badda12f413e55b6 | |
parent | 3d2bf93ebfb3da81215e1ec381ba9cab00535ba3 (diff) | |
download | tcl-06f7470662af25ea53cefea3f2e731cbf6ce2eaf.zip tcl-06f7470662af25ea53cefea3f2e731cbf6ce2eaf.tar.gz tcl-06f7470662af25ea53cefea3f2e731cbf6ce2eaf.tar.bz2 |
mac resource freeing fix
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | mac/tclMacResource.c | 11 | ||||
-rw-r--r-- | tests/resource.test | 6 |
3 files changed, 20 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2003-10-23 Vince Darley <vincentdarley@users.sourceforge.net> + + * tests/resource.test: + * mac/tclMacResource.c: fix to resource freeing problem in 'resource' + command reported by Bernard Desgraupes. + 2003-10-22 Donal K. Fellows <fellowsd@cs.man.ac.uk> * generic/tclCmdAH.c (Tcl_FileObjCmd): Changed FILE_ prefix to FCMD_ diff --git a/mac/tclMacResource.c b/mac/tclMacResource.c index 2403ebf..aff6bed 100644 --- a/mac/tclMacResource.c +++ b/mac/tclMacResource.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: tclMacResource.c,v 1.18 2003/10/14 15:44:53 dgp Exp $ + * RCS: @(#) $Id: tclMacResource.c,v 1.19 2003/10/23 10:07:09 vincentdarley Exp $ */ #include <Errors.h> @@ -478,7 +478,14 @@ resourceRef? resourceType"); } else { objPtr = Tcl_NewIntObj(id); } - ReleaseResource(resource); + /* + * If the Master Pointer of the returned handle is + * null, then resource was not in memory, and it is + * safe to release it. Otherwise, it is not. + */ + if (*resource == NULL) { + ReleaseResource(resource); + } result = Tcl_ListObjAppendElement(interp, resultPtr, objPtr); if (result != TCL_OK) { diff --git a/tests/resource.test b/tests/resource.test index f968769..a650d48 100644 --- a/tests/resource.test +++ b/tests/resource.test @@ -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: resource.test,v 1.8 2003/10/06 14:32:22 dgp Exp $ +# RCS: @(#) $Id: resource.test,v 1.9 2003/10/23 10:07:30 vincentdarley Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -148,6 +148,10 @@ test resource-5.4 {resource types tests} {macOnly} { resource close $id set result } {TEXT} +test resource-5.5 {resource types lists} {macOnly} { + # This should not crash + catch {foreach f [resource types] { resource list $f }} +} {0} # resource write tests test resource-6.1 {resource write tests} {macOnly} { |