Fossil SCM

Initialize the output buffer for blob_compress prior to invoking zlib in order to avoid valgrind warnings about reading uninitialized memory.

drh 2011-05-12 14:04 trunk
Commit c9bb729d5df44cab1ec52314a51280a25f7cc2b7
1 file changed +1
+1
--- src/blob.c
+++ src/blob.c
@@ -783,10 +783,11 @@
783783
unsigned char *outBuf;
784784
Blob temp;
785785
blob_zero(&temp);
786786
blob_resize(&temp, nOut+4);
787787
outBuf = (unsigned char*)blob_buffer(&temp);
788
+ memset(outBuf, 0, nOut+4);
788789
outBuf[0] = nIn>>24 & 0xff;
789790
outBuf[1] = nIn>>16 & 0xff;
790791
outBuf[2] = nIn>>8 & 0xff;
791792
outBuf[3] = nIn & 0xff;
792793
nOut2 = (long int)nOut;
793794
--- src/blob.c
+++ src/blob.c
@@ -783,10 +783,11 @@
783 unsigned char *outBuf;
784 Blob temp;
785 blob_zero(&temp);
786 blob_resize(&temp, nOut+4);
787 outBuf = (unsigned char*)blob_buffer(&temp);
 
788 outBuf[0] = nIn>>24 & 0xff;
789 outBuf[1] = nIn>>16 & 0xff;
790 outBuf[2] = nIn>>8 & 0xff;
791 outBuf[3] = nIn & 0xff;
792 nOut2 = (long int)nOut;
793
--- src/blob.c
+++ src/blob.c
@@ -783,10 +783,11 @@
783 unsigned char *outBuf;
784 Blob temp;
785 blob_zero(&temp);
786 blob_resize(&temp, nOut+4);
787 outBuf = (unsigned char*)blob_buffer(&temp);
788 memset(outBuf, 0, nOut+4);
789 outBuf[0] = nIn>>24 & 0xff;
790 outBuf[1] = nIn>>16 & 0xff;
791 outBuf[2] = nIn>>8 & 0xff;
792 outBuf[3] = nIn & 0xff;
793 nOut2 = (long int)nOut;
794

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button