summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-05-20 02:41:26 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-05-20 02:41:26 (GMT)
commit511a4b5d5ef8ff90218dd3aa8c85478bd5f56a36 (patch)
treeff86d8f8fff8dc3559eef37260e888f9811adef0
parentbc6490bcc6ca0eb4d50562f811e25949bda0701c (diff)
downloadtk-511a4b5d5ef8ff90218dd3aa8c85478bd5f56a36.zip
tk-511a4b5d5ef8ff90218dd3aa8c85478bd5f56a36.tar.gz
tk-511a4b5d5ef8ff90218dd3aa8c85478bd5f56a36.tar.bz2
Initialize memory to stop valgrind notices about conditionals dependent on
reads from uninit memory.
-rw-r--r--generic/tkImgGIF.c7
-rw-r--r--generic/tkImgPhoto.c3
2 files changed, 10 insertions, 0 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 27de486..6273c69 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -410,6 +410,7 @@ FileReadGIF(
* source and not a file.
*/
+ memset(colorMap, 0, MAXCOLORMAPSIZE*4);
memset(gifConfPtr, 0, sizeof(GIFImageConfig));
if (fileName == INLINE_DATA_BINARY || fileName == INLINE_DATA_BASE64) {
gifConfPtr->fromData = fileName;
@@ -592,6 +593,9 @@ FileReadGIF(
if (trashBuffer == NULL) {
nBytes = fileWidth * fileHeight * 3;
trashBuffer = ckalloc(nBytes);
+ if (trashBuffer) {
+ memset(trashBuffer, 0, nBytes);
+ }
}
/*
@@ -678,6 +682,9 @@ FileReadGIF(
block.pitch = block.pixelSize * imageWidth;
nBytes = block.pitch * imageHeight;
block.pixelPtr = ckalloc(nBytes);
+ if (block.pixelPtr) {
+ memset(block.pixelPtr, 0, nBytes);
+ }
if (ReadImage(gifConfPtr, interp, block.pixelPtr, chan, imageWidth,
imageHeight, colorMap, srcX, srcY, BitSet(buf[8], INTERLACE),
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index fcb6d2f..7fa894c 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -2075,6 +2075,9 @@ ToggleComplexAlphaIfNeeded(
*/
mPtr->flags &= ~COMPLEX_ALPHA;
+ if (c == NULL) {
+ return 0;
+ }
c += 3; /* Start at first alpha byte. */
for (; c < end; c += 4) {
if (*c && *c != 255) {