From 1743ac47348ad82b00d476858e9c7aa4dc8554e6 Mon Sep 17 00:00:00 2001 From: Nathaniel Quillin Date: Mon, 20 Jul 2020 23:49:32 -0700 Subject: [PATCH] Initialize offset memory for PyImagingPhotoPut. When using image mode "1" or "L" block.offset[3] is never initialized. In some use cases the block is passed to Tk_PhotoPutBlock (https://github.com/tcltk/tk/blob/master/generic/tkImgPhoto.c#L2752) and block.offset[3] is stored in alphaoffset which is later referenced. --- src/Tk/tkImaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tk/tkImaging.c b/src/Tk/tkImaging.c index 161a835fbd2..aca84523cb8 100644 --- a/src/Tk/tkImaging.c +++ b/src/Tk/tkImaging.c @@ -114,7 +114,7 @@ PyImagingPhotoPut(ClientData clientdata, Tcl_Interp* interp, if (strcmp(im->mode, "1") == 0 || strcmp(im->mode, "L") == 0) { block.pixelSize = 1; - block.offset[0] = block.offset[1] = block.offset[2] = 0; + block.offset[0] = block.offset[1] = block.offset[2] = block.offset[3] = 0; } else if (strncmp(im->mode, "RGB", 3) == 0) { block.pixelSize = 4; block.offset[0] = 0;