diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-25 16:27:09 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-03-25 16:27:09 (GMT) |
commit | 295b02cdfbc034362af781b66d116e86198e8dd7 (patch) | |
tree | 93600b9e99833d233f9dd9f53b3a0d0fb66f8d38 /generic | |
parent | 79d9b8f4f92351811a39d4f9a58437208ee762d0 (diff) | |
download | tk-295b02cdfbc034362af781b66d116e86198e8dd7.zip tk-295b02cdfbc034362af781b66d116e86198e8dd7.tar.gz tk-295b02cdfbc034362af781b66d116e86198e8dd7.tar.bz2 |
Fix [76646bdf6]: "photo get" command leaks memory
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkImgPhoto.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index bb9416e..f45fac5 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -940,7 +940,7 @@ ImgPhotoCmd( */ Tcl_Obj *channels[4]; - int channelCount = 3; + int i, channelCount = 3; index = 3; memset(&options, 0, sizeof(options)); @@ -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; } |