mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-15 01:34:45 +03:00
prevent Valgrind errors about using uninitialized memory
This commit is contained in:
parent
13e3120925
commit
b178d1621a
|
@ -381,7 +381,7 @@ ImagingDestroyArray(Imaging im) {
|
||||||
|
|
||||||
Imaging
|
Imaging
|
||||||
ImagingAllocateArray(Imaging im, int dirty, int block_size) {
|
ImagingAllocateArray(Imaging im, int dirty, int block_size) {
|
||||||
int y, line_in_block, current_block;
|
int y, x, line_in_block, current_block;
|
||||||
ImagingMemoryArena arena = &ImagingDefaultArena;
|
ImagingMemoryArena arena = &ImagingDefaultArena;
|
||||||
ImagingMemoryBlock block = {NULL, 0};
|
ImagingMemoryBlock block = {NULL, 0};
|
||||||
int aligned_linesize, lines_per_block, blocks_count;
|
int aligned_linesize, lines_per_block, blocks_count;
|
||||||
|
@ -442,6 +442,18 @@ ImagingAllocateArray(Imaging im, int dirty, int block_size) {
|
||||||
|
|
||||||
im->destroy = ImagingDestroyArray;
|
im->destroy = ImagingDestroyArray;
|
||||||
|
|
||||||
|
/* Zero-out the unused bytes for image modes that
|
||||||
|
only use 3 of 4 bytes to prevent Valgrind errors */
|
||||||
|
if (dirty && im->bands == 3 && im->pixelsize == 4) {
|
||||||
|
for (y = 0; y < im->ysize; y++) {
|
||||||
|
char *line = im->image[y] + 3;
|
||||||
|
for (x = 0; x < im->xsize; x++) {
|
||||||
|
*line = 0;
|
||||||
|
line += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user