diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-02-09 14:40:30 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-02-09 14:40:30 (GMT) |
commit | fa4294508199ab16097f7839aabfad245988cf89 (patch) | |
tree | 140363945375e380f5a86f7aa28b0f838b83757f /generic | |
parent | 2b24ae2bc9092c28741230374ad002956c719396 (diff) | |
download | tk-fa4294508199ab16097f7839aabfad245988cf89.zip tk-fa4294508199ab16097f7839aabfad245988cf89.tar.gz tk-fa4294508199ab16097f7839aabfad245988cf89.tar.bz2 |
Stop crashes when copying a large photo to itself causes resizing. [Bug 877950]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkImgPhoto.c | 9 |
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; } } |