summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPhoto.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-10 12:31:55 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-10 12:31:55 (GMT)
commitae6c3c15f60d72b35c871fbfc3f29269c2a3405b (patch)
tree228fbaa9f5048b25e8d826c005fad09b990c8b56 /generic/tkImgPhoto.c
parente9f1a4f1b05e6570c1e5f05f50af070153b9fe87 (diff)
parent77321e10c36d6e107a3dab3eb0ac41a7bcf8632e (diff)
downloadtk-ae6c3c15f60d72b35c871fbfc3f29269c2a3405b.zip
tk-ae6c3c15f60d72b35c871fbfc3f29269c2a3405b.tar.gz
tk-ae6c3c15f60d72b35c871fbfc3f29269c2a3405b.tar.bz2
Merge 8.6
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r--generic/tkImgPhoto.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 7f3f228..647eb17 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -657,9 +657,6 @@ ImgPhotoCmd(
if ((options.fromX2 > block.width) || (options.fromY2 > block.height)
|| (options.fromX2 > block.width)
|| (options.fromY2 > block.height)) {
- if (options.background) {
- Tk_FreeColor(options.background);
- }
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside source image",
-1));
@@ -736,9 +733,6 @@ ImgPhotoCmd(
if (options.options & OPT_SHRINK) {
if (ImgPhotoSetSize(modelPtr, options.toX2,
options.toY2) != TCL_OK) {
- if (options.background) {
- Tk_FreeColor(options.background);
- }
Tcl_SetObjResult(interp, Tcl_NewStringObj(
TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
@@ -749,9 +743,6 @@ ImgPhotoCmd(
Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
}
- if (options.background) {
- Tk_FreeColor(options.background);
- }
return result;
case PHOTO_DATA: {
@@ -781,6 +772,9 @@ ImgPhotoCmd(
}
if ((options.name == NULL) || (index < objc)) {
Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?");
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
if ((options.fromX > modelPtr->width)
@@ -790,6 +784,9 @@ ImgPhotoCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside image", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
@@ -913,21 +910,21 @@ ImgPhotoCmd(
if (data) {
ckfree(data);
}
- if (freeObj != NULL) {
- Tcl_DecrRefCount(freeObj);
- }
+ if (freeObj != NULL) {
+ Tcl_DecrRefCount(freeObj);
+ }
return result;
dataErrorExit:
- if (options.background) {
+ if (options.background) {
Tk_FreeColor(options.background);
}
if (data) {
ckfree(data);
}
- if (freeObj != NULL) {
- Tcl_DecrRefCount(freeObj);
- }
+ if (freeObj != NULL) {
+ Tcl_DecrRefCount(freeObj);
+ }
return TCL_ERROR;
}
@@ -1444,6 +1441,9 @@ readCleanup:
}
if ((options.name == NULL) || (index < objc)) {
Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?");
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
if ((options.fromX > modelPtr->width)
@@ -1453,6 +1453,9 @@ readCleanup:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"coordinates for -from option extend outside image", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL);
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
@@ -1561,6 +1564,9 @@ readCleanup:
}
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
fmtString, NULL);
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
@@ -2140,7 +2146,6 @@ ImgPhotoConfigureModel(
if ((modelPtr->fileString != NULL)
&& ((modelPtr->fileString != oldFileString)
|| (modelPtr->format != oldFormat))) {
-
/*
* Prevent file system access in a safe interpreter.
*/