Skip to content

Commit

Permalink
Fix [76646bdf6]: "photo get" command leaks memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Mar 25, 2024
1 parent 79d9b8f commit 295b02c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions generic/tkImgPhoto.c
Expand Up @@ -940,7 +940,7 @@ ImgPhotoCmd(
*/

Tcl_Obj *channels[4];
int channelCount = 3;
int i, channelCount = 3;

index = 3;
memset(&options, 0, sizeof(options));
Expand Down Expand Up @@ -976,10 +976,9 @@ ImgPhotoCmd(
*/

pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
channels[0] = Tcl_NewWideIntObj(pixelPtr[0]);
channels[1] = Tcl_NewWideIntObj(pixelPtr[1]);
channels[2] = Tcl_NewWideIntObj(pixelPtr[2]);
channels[3] = Tcl_NewWideIntObj(pixelPtr[3]);
for (i = 0; i < channelCount; i++) {
channels[i] = Tcl_NewWideIntObj(pixelPtr[i]);
}
Tcl_SetObjResult(interp, Tcl_NewListObj(channelCount, channels));
return TCL_OK;
}
Expand Down

0 comments on commit 295b02c

Please sign in to comment.