Skip to content

Commit

Permalink
Fix potential uninitialized variable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
derobins committed Sep 26, 2023
1 parent 4233ae6 commit af0d4f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/src/h5perf/sio_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++) {
Expand Down

0 comments on commit af0d4f5

Please sign in to comment.