diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkImgPhoto.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 8b7350d..1fec208 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -2740,23 +2740,23 @@ Tk_PhotoPutBlock( /* * Fix for bug e4336bef5d: - * + * * Make a local copy of *blockPtr, as we might have to change some * of its fields and don't want to interfere with the caller's data. - * - * If source and destination are the same image, create a copy of the + * + * If source and destination are the same image, create a copy of the * source data in our local sourceBlock. - * + * * To find out, just comparing the pointers is not enough - they might have * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ sourceBlock = *blockPtr; memToFree = NULL; - if (sourceBlock.pixelPtr >= masterPtr->pix32 + if (sourceBlock.pixelPtr >= masterPtr->pix32 && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width * masterPtr->height * 4) { - sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height + sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height * sourceBlock.pitch); if (sourceBlock.pixelPtr == NULL) { if (interp != NULL) { @@ -2767,11 +2767,11 @@ Tk_PhotoPutBlock( return TCL_ERROR; } memToFree = sourceBlock.pixelPtr; - memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height + memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height * sourceBlock.pitch); } - - + + xEnd = x + width; yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { @@ -3085,14 +3085,14 @@ Tk_PhotoPutBlock( Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width, masterPtr->height); - - ckfree(memToFree); - + + if (memToFree) ckfree(memToFree); + return TCL_OK; - + errorExit: - ckfree(memToFree); - + if (memToFree) ckfree(memToFree); + return TCL_ERROR; } @@ -3172,25 +3172,25 @@ Tk_PhotoPutZoomedBlock( if (width <= 0 || height <= 0) { return TCL_OK; } - + /* * Fix for Bug e4336bef5d: * Make a local copy of *blockPtr, as we might have to change some * of its fields and don't want to interfere with the caller's data. - * - * If source and destination are the same image, create a copy of the + * + * If source and destination are the same image, create a copy of the * source data in our local sourceBlock. - * + * * To find out, just comparing the pointers is not enough - they might have * different values and still point to the same block of memory. (e.g. * if the -from option was passed to [imageName copy]) */ sourceBlock = *blockPtr; memToFree = NULL; - if (sourceBlock.pixelPtr >= masterPtr->pix32 + if (sourceBlock.pixelPtr >= masterPtr->pix32 && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width * masterPtr->height * 4) { - sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height + sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height * sourceBlock.pitch); if (sourceBlock.pixelPtr == NULL) { if (interp != NULL) { @@ -3201,7 +3201,7 @@ Tk_PhotoPutZoomedBlock( return TCL_ERROR; } memToFree = sourceBlock.pixelPtr; - memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height + memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height * sourceBlock.pitch); } @@ -3429,14 +3429,14 @@ Tk_PhotoPutZoomedBlock( Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width, masterPtr->height); - - ckfree(memToFree); - + + if (memToFree) ckfree(memToFree); + return TCL_OK; - + errorExit: - ckfree(memToFree); - + if (memToFree) ckfree(memToFree); + return TCL_ERROR; } |