summaryrefslogtreecommitdiffstats
path: root/test/stab.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-02-02 02:42:36 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-02-02 02:42:36 (GMT)
commit94747604008862cf1038b3964f5b99e3bfe2b8ad (patch)
tree0bf02189287d79af2ee6d7d8f486822c6c6b5650 /test/stab.c
parent6774149c1724f2ed27acf5eb025b8f74fb4f5aba (diff)
downloadhdf5-94747604008862cf1038b3964f5b99e3bfe2b8ad.zip
hdf5-94747604008862cf1038b3964f5b99e3bfe2b8ad.tar.gz
hdf5-94747604008862cf1038b3964f5b99e3bfe2b8ad.tar.bz2
[svn-r23220] Description:
Bring r23219 from trunk to 1.8 branch: Bring reviewed changes from Coverity branch back to trunk (QK & JK): r20457: Coverity issue 691: return of H5duo could be negative. Fixed by using STDOUT_FILENO and redesign parse_command_line and main to cleanup file allocations. The output_file var is null when using stdout. In cleanup do not close output_file if NULL. r20510: Initialize ufid = -1 and predicate HDclose call on ufid != -1 r20511: Purpose: Fix coverity issue 1715 Description: Free "file" and nested data on failure in H5FD_core_open. r20512: Initialize ifid = -1 and predicate HDclose call on ifid != -1 r20514: Initialize h5fid = -1 and predicate HDclose call on h5fid != -1 r20516: Added else branch to the if (ret_value < 0) check. r20522: Addressed coverity issues 930-933, 850, 836, 835, 1307. All minor potential buffer overwrite bugs, or coverity errors. Fixed by replacing strcpy and sprintf with strncpy and snprintf. r20523: fixed coverity issues 68, 1120, 1116i r20524: Check H5Z_SZIP->encoder_present < 1 assuming 0 represents absence. r20601: Purpose: Fix coverity issues 1703-1705 Description: Modified the cleanup code in test_free in accum.c to reset allocated buffers to NULL after they are freed, and modified the error cleanup code to check if these buffers are NULL before freeing them. Also fixed some unrelated warnings in accum.c. r20602: Use HDsnprintf and HDstrncat r20603: Purpose: Fix coverity issues 808-809 Description: Modified test_core in vfd.c to check the returns from malloc, and keep track of whether points and check are allocated by setting them to NULL when they are not. Added code to free points and check on error if they are not NULL. Also fixed unrelated warnings in vfd.c. r20604: Use HDstrncpy. r20605: Use HDstrncpy and HDstrncat. r20606: Purpose: Fix coverity issue 807 Description: Modified long_compact in stab.c to keep track of whether objname is allocated by setting it to NULL when it is not. Added code to free objname on error if it is not NULL. r20607: Changed string function calls to use versions that specify the string length to fix coverity issues 832 and 839. Tested on: Mac OSX/64 10.8.2 (amazon) (Too minor to require h5committest)
Diffstat (limited to 'test/stab.c')
-rw-r--r--test/stab.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/stab.c b/test/stab.c
index a42ee5e..48b58b1 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -539,7 +539,7 @@ long_compact(hid_t fapl2)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group ID */
hid_t gid2 = (-1); /* Group ID */
- char *objname; /* Object name */
+ char *objname = NULL; /* Object name */
char filename[NAME_BUF_SIZE];
h5_stat_size_t empty_size; /* Size of an empty file */
h5_stat_size_t file_size; /* Size of each file created */
@@ -557,7 +557,7 @@ long_compact(hid_t fapl2)
if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Construct very long object name template */
- if((objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1))) == NULL) TEST_ERROR
+ if(NULL == (objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1)))) TEST_ERROR
HDmemset(objname, 'a', (size_t)LONG_COMPACT_LENGTH);
objname[LONG_COMPACT_LENGTH] = '\0';
@@ -620,6 +620,7 @@ long_compact(hid_t fapl2)
/* Free object name */
HDfree(objname);
+ objname = NULL;
/* Close top group */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -645,6 +646,10 @@ error:
H5Gclose(gid);
H5Fclose(fid);
} H5E_END_TRY;
+
+ if(objname)
+ HDfree(objname);
+
return 1;
} /* end long_compact() */