diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2003-02-18 14:03:46 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2003-02-18 14:03:46 (GMT) |
commit | 44b61812110005586046fa2528127d71e3f8356a (patch) | |
tree | 4e75c6657880609b0fc3106856cdffdc69c62915 | |
parent | 3140b466ac0f4bbd52a522217ec17093da9cf37c (diff) | |
download | tk-44b61812110005586046fa2528127d71e3f8356a.zip tk-44b61812110005586046fa2528127d71e3f8356a.tar.gz tk-44b61812110005586046fa2528127d71e3f8356a.tar.bz2 |
* generic/tkImgGIF.c (FileReadGIF): Ensure that the trashBuffer is
always deallocated on function exit to stop a potential memory leak.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tkImgGIF.c | 22 |
2 files changed, 18 insertions, 9 deletions
@@ -1,3 +1,8 @@ +2003-02-18 Donal K. Fellows <fellowsd@cs.man.ac.uk> + + * generic/tkImgGIF.c (FileReadGIF): Ensure that the trashBuffer is + always deallocated on function exit to stop a potential memory leak. + 2003-02-17 Mo DeJong <mdejong@users.sourceforge.net> * generic/tkEvent.c (Tk_HandleEvent): Fixup button diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index e952afb..b34365e 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -29,7 +29,7 @@ * | provided "as is" without express or implied warranty. | * +-------------------------------------------------------------------+ * - * RCS: @(#) $Id: tkImgGIF.c,v 1.22 2002/08/08 09:35:08 hobbs Exp $ + * RCS: @(#) $Id: tkImgGIF.c,v 1.23 2003/02/18 14:03:46 dkf Exp $ */ /* @@ -424,13 +424,6 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, continue; } - /* - * If a trash buffer has been allocated, free it now. - */ - if (trashBuffer != NULL) { - ckfree((char *)trashBuffer); - trashBuffer = NULL; - } if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(chan, bitPixel, colorMap)) { Tcl_AppendResult(interp, "error reading color map", @@ -485,6 +478,12 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, TK_PHOTO_COMPOSITE_SET); noerror: + /* + * If a trash buffer has been allocated, free it now. + */ + if (trashBuffer != NULL) { + ckfree((char *)trashBuffer); + } if (block.pixelPtr) { ckfree((char *) block.pixelPtr); } @@ -492,11 +491,16 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, return TCL_OK; error: + /* + * If a trash buffer has been allocated, free it now. + */ + if (trashBuffer != NULL) { + ckfree((char *)trashBuffer); + } if (block.pixelPtr) { ckfree((char *) block.pixelPtr); } return TCL_ERROR; - } /* |