summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-09-14 20:15:05 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-09-14 20:15:05 (GMT)
commit62847af89d0e7df4117135e9fbbcf30ef0546874 (patch)
tree5d3a848ec2e8a0390bfed145838d3a71f0494826 /generic
parentda54602493ccf28707320190ca559915a08e3003 (diff)
downloadtk-62847af89d0e7df4117135e9fbbcf30ef0546874.zip
tk-62847af89d0e7df4117135e9fbbcf30ef0546874.tar.gz
tk-62847af89d0e7df4117135e9fbbcf30ef0546874.tar.bz2
Fix [5239fd749b]: Segfault when copying a photo image to itself. Patch from Simon Bachmann.bug_5239fd749b
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgPhoto.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 1fec208..cb46c41 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -625,7 +625,24 @@ ImgPhotoCmd(
}
/*
+ * Copy the image data over using Tk_PhotoPutZoomedBlock.
+ */
+
+ block.pixelPtr += options.fromX * block.pixelSize
+ + options.fromY * block.pitch;
+ block.width = options.fromX2 - options.fromX;
+ block.height = options.fromY2 - options.fromY;
+ result = Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) masterPtr,
+ &block, options.toX, options.toY, options.toX2 - options.toX,
+ options.toY2 - options.toY, options.zoomX, options.zoomY,
+ options.subsampleX, options.subsampleY,
+ options.compositingRule);
+
+ /*
* Set the destination image size if the -shrink option was specified.
+ * This has to be done _after_ copying the data. Otherwise, if source
+ * and destination are the same image, block.pixelPtr would point to
+ * an invalid memory block (bug [5239fd749b]).
*/
if (options.options & OPT_SHRINK) {
@@ -637,20 +654,9 @@ ImgPhotoCmd(
return TCL_ERROR;
}
}
-
- /*
- * Copy the image data over using Tk_PhotoPutZoomedBlock.
- */
-
- block.pixelPtr += options.fromX * block.pixelSize
- + options.fromY * block.pitch;
- block.width = options.fromX2 - options.fromX;
- block.height = options.fromY2 - options.fromY;
- return Tk_PhotoPutZoomedBlock(interp, (Tk_PhotoHandle) masterPtr,
- &block, options.toX, options.toY, options.toX2 - options.toX,
- options.toY2 - options.toY, options.zoomX, options.zoomY,
- options.subsampleX, options.subsampleY,
- options.compositingRule);
+ Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
+ masterPtr->width, masterPtr->height);
+ return result;
case PHOTO_DATA: {
char *data;