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>
Sun, 7 Aug 2011 18:50:08 +0000 (11:50 -0700)
In error conditions, charList could be freed before it is initialized.
Move the initialization up to before the error checks.

Change-Id: I678f40552590e238f494507f7410233cdbb949ac
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>

src/butc/tcudbprocs.c

index b4424d8..3fe76f5 100644 (file)
@@ -415,6 +415,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)
@@ -445,8 +447,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 */