summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2023-09-27 14:56:25 (GMT)
committerGitHub <noreply@github.com>2023-09-27 14:56:25 (GMT)
commitd8fbc56f780109e59184804c0c2704475d4ef41b (patch)
tree1ff1201b3969821d6013b4d51cbf3f8d8c9fb27a /tools
parentb892c43e4968339c72a8897cd3c48834f67d680c (diff)
downloadhdf5-d8fbc56f780109e59184804c0c2704475d4ef41b.zip
hdf5-d8fbc56f780109e59184804c0c2704475d4ef41b.tar.gz
hdf5-d8fbc56f780109e59184804c0c2704475d4ef41b.tar.bz2
Fix potential uninitialized variable (#3602)
Moves a union initialization up a bit so it's performed before code that can jump to the cleanup target, where file descriptors could be checked without being initialized. This could only happen in test code and only in an out-of-memory situation. Fixes Coverity 1542254
Diffstat (limited to 'tools')
-rw-r--r--tools/src/h5perf/sio_engine.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c
index 700416d..2363f6a 100644
--- a/tools/src/h5perf/sio_engine.c
+++ b/tools/src/h5perf/sio_engine.c
@@ -139,9 +139,7 @@ do_sio(parameters param, results *res)
/* IO type */
iot = param.io_type;
- if (NULL == (fname = calloc(FILENAME_MAX, sizeof(char))))
- GOTOERROR(FAIL);
-
+ /* MUST initialize fd early since we check its file IDs in cleanup code */
switch (iot) {
case POSIXIO:
fd.posixfd = -1;
@@ -157,6 +155,9 @@ do_sio(parameters param, results *res)
GOTOERROR(FAIL);
}
+ if (NULL == (fname = calloc(FILENAME_MAX, sizeof(char))))
+ GOTOERROR(FAIL);
+
linear_buf_size = 1;
for (i = 0; i < param.rank; i++) {