libbb: dump: do not use uninitialized memory. close bug 4364.
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 29 Jul 2008 00:00:14 +0000 (00:00 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 29 Jul 2008 00:00:14 +0000 (00:00 -0000)
libbb/dump.c

index 0d553d4d07f3093a65f09041e95043dd3369951e..74c5e1691753f965a7d543d4f029020aa812a44d 100644 (file)
@@ -376,17 +376,16 @@ static unsigned char *get(priv_dumper_t *dumper)
 {
        int n;
        int need, nread;
-       unsigned char *tmpp;
        int blocksize = dumper->blocksize;
 
        if (!dumper->get__curp) {
                dumper->address = (off_t)0; /*DBU:[dave@cray.com] initialize,initialize..*/
                dumper->get__curp = xmalloc(blocksize);
-               dumper->get__savp = xmalloc(blocksize);
+               dumper->get__savp = xzalloc(blocksize); /* need to be initialized */
        } else {
-               tmpp = dumper->get__curp;
+               unsigned char *tmp = dumper->get__curp;
                dumper->get__curp = dumper->get__savp;
-               dumper->get__savp = tmpp;
+               dumper->get__savp = tmp;
                dumper->savaddress += blocksize;
                dumper->address = dumper->savaddress;
        }