summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPhoto.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-02-09 14:40:30 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-02-09 14:40:30 (GMT)
commit5e1a7db351894f12bed8acd58aa4d95b72548532 (patch)
tree140363945375e380f5a86f7aa28b0f838b83757f /generic/tkImgPhoto.c
parentddbf41804636015e174c51c243ef250fe5a5d8cb (diff)
downloadtk-5e1a7db351894f12bed8acd58aa4d95b72548532.zip
tk-5e1a7db351894f12bed8acd58aa4d95b72548532.tar.gz
tk-5e1a7db351894f12bed8acd58aa4d95b72548532.tar.bz2
Stop crashes when copying a large photo to itself causes resizing. [Bug 877950]
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r--generic/tkImgPhoto.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 5bec1a6..d525660 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -17,7 +17,7 @@
* Department of Computer Science,
* Australian National University.
*
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.3 2003/11/11 00:05:19 hobbs Exp $
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.4 2004/02/09 14:40:31 dkf Exp $
*/
#include "tkInt.h"
@@ -4263,12 +4263,18 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, compRule)
xEnd = x + width;
yEnd = y + height;
if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
+ int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32);
if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE);
}
+ if (sameSrc) {
+ blockPtr->pixelPtr = masterPtr->pix32;
+ blockPtr->pitch = masterPtr->width * 4;
+ }
}
+
if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
&& (x < masterPtr->ditherX))) {
/*
@@ -4569,6 +4575,7 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY,
}
if (sameSrc) {
blockPtr->pixelPtr = masterPtr->pix32;
+ blockPtr->pitch = masterPtr->width * 4;
}
}