]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
butc: avoid freeing uninitialized pointer in writeDbDump()
authorGarrett Wollman <wollman@csail.mit.edu>
Sun, 7 Aug 2011 03:55:50 +0000 (23:55 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 12 Aug 2011 15:51:30 +0000 (08:51 -0700)
In error conditions, charList could be freed before it is initialized.
Move the initialization up to before the error checks.

Found-by: clang static analyzer
Reviewed-on: http://gerrit.openafs.org/5167
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 43834bff1a2b1af348ff69d538a884bf1070b90c)

Change-Id: I05d1602b3f59b521d7daa3fd23f6609bf14c460e
Reviewed-on: http://gerrit.openafs.org/5224
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/butc/tcudbprocs.c

index 82b3d0474b40ac854bbb38287a2d9199b2abeffd..6b61a326765754c03666e5522110fca47bda078d 100644 (file)
@@ -430,6 +430,8 @@ writeDbDump(struct butm_tapeInfo *tapeInfoPtr, afs_uint32 taskId,
     extern struct tapeConfig globalTapeConfig;
     extern struct udbHandleS udbHandle;
 
+    charList.charListT_val = 0;
+    charList.charListT_len = 0;
     blockSize = BUTM_BLKSIZE;
     writeBlock = (char *)malloc(BUTM_BLOCKSIZE);
     if (!writeBlock)
@@ -460,8 +462,6 @@ writeDbDump(struct butm_tapeInfo *tapeInfoPtr, afs_uint32 taskId,
     writeBufPtr = &writeBuffer[0];
     firstcall = 1;
     sequence = 1;
-    charList.charListT_val = 0;
-    charList.charListT_len = 0;
 
     while (1) {                        /*w */
        /* When no data in buffer, read data from the budb_server */