diff options
Diffstat (limited to 'generic/tkImgGIF.c')
-rw-r--r-- | generic/tkImgGIF.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 9b70344..6368972 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -704,6 +704,7 @@ FileReadGIF( } if ((width > 0) && (height > 0)) { + unsigned char* pixelPtr; Tk_PhotoImageBlock block; int transparent = -1; if (gifGraphicControlExtensionBlock.blockPresent) { @@ -729,23 +730,25 @@ FileReadGIF( goto error; } nBytes = block.pitch * imageHeight; - block.pixelPtr = (unsigned char *)ckalloc(nBytes); - if (block.pixelPtr) { - memset(block.pixelPtr, 0, nBytes); + pixelPtr = (unsigned char*)ckalloc(nBytes); + if (pixelPtr) { + memset(pixelPtr, 0, nBytes); } + block.pixelPtr = pixelPtr; if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth, imageHeight, colorMap, srcX, srcY, BitSet(buf[8], INTERLACE), transparent) != TCL_OK) { - ckfree(block.pixelPtr); + ckfree(pixelPtr); goto error; } + block.pixelPtr += srcX * block.pixelSize + srcY * block.pitch; if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) { - ckfree(block.pixelPtr); + ckfree(pixelPtr); goto error; } - ckfree(block.pixelPtr); + ckfree(pixelPtr); } /* |