summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-09 17:11:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-12-09 17:11:59 (GMT)
commit72801b6d102a7cc69663a41ce6611bf14010e343 (patch)
treeef05668da354b0a9b7e91789412ee498a6382680 /generic
parent98ca1fc00fa7d5b8ab24e8630ac36d932fa79776 (diff)
downloadtk-72801b6d102a7cc69663a41ce6611bf14010e343.zip
tk-72801b6d102a7cc69663a41ce6611bf14010e343.tar.gz
tk-72801b6d102a7cc69663a41ce6611bf14010e343.tar.bz2
Fix [25894d41c2]: correcting usage of Tk_FreeColor() in ImgPhotoCmd()
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgPhoto.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 9e3c80f..03c5c9e 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -576,9 +576,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));
@@ -655,9 +652,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);
@@ -668,9 +662,6 @@ ImgPhotoCmd(
Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
}
- if (options.background) {
- Tk_FreeColor(options.background);
- }
return result;
case PHOTO_DATA: {
@@ -695,6 +686,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)
@@ -704,6 +698,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;
}
@@ -755,6 +752,9 @@ ImgPhotoCmd(
(matched ? "not supported" : "unknown")));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
Tcl_GetString(options.format), NULL);
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}
} else {
@@ -1331,6 +1331,9 @@ ImgPhotoCmd(
}
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)
@@ -1340,6 +1343,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;
}
@@ -1419,6 +1425,9 @@ ImgPhotoCmd(
}
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
fmtString, NULL);
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
return TCL_ERROR;
}