From f648519f2e7008d81a29113d6ce23158dcd37bcf Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Sat, 6 Aug 2011 23:55:50 -0400 Subject: [PATCH] butc: avoid freeing uninitialized pointer in writeDbDump() 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 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear (cherry picked from commit 43834bff1a2b1af348ff69d538a884bf1070b90c) Change-Id: I05d1602b3f59b521d7daa3fd23f6609bf14c460e Reviewed-on: http://gerrit.openafs.org/5224 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/butc/tcudbprocs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/butc/tcudbprocs.c b/src/butc/tcudbprocs.c index 82b3d0474..6b61a3267 100644 --- a/src/butc/tcudbprocs.c +++ b/src/butc/tcudbprocs.c @@ -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 */ -- 2.39.5