Skip to content

Commit 534cf08

Browse files
krempel-ptrhc54
authored andcommitted
Fix potential use after free in tests
Signed-off-by: Stephan Krempel <[email protected]>
1 parent d94a533 commit 534cf08

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

test/test_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ extern FILE *file;
9999
char *fname = malloc(strlen(prefix) + MAX_DIGIT_LEN + 2); \
100100
sprintf(fname, "%s.%d.%d", prefix, ns_id, rank); \
101101
file = fopen(fname, "w"); \
102-
free(fname); \
103102
if (NULL == file) { \
104103
fprintf(stderr, "Cannot open file %s for writing!", fname); \
105104
exit(1); \
106105
} \
106+
free(fname); \
107107
}
108108

109109
#define TEST_CLOSE_FILE() \

test/test_v2/test_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ extern FILE *pmixt_outfile;
127127
char *fname = malloc( strlen(prefix) + MAX_DIGIT_LEN + 2 ); \
128128
sprintf(fname, "%s.%d.%d", prefix, ns_id, rank); \
129129
pmixt_outfile = fopen(fname, "w"); \
130-
free(fname); \
131130
if( NULL == pmixt_outfile ){ \
132131
fprintf(stderr, "Cannot open file %s for writing!", fname); \
133132
exit(1); \
134133
} \
134+
free(fname); \
135135
}
136136

137137
#define PMIXT_CLOSE_FILE() { \

0 commit comments

Comments
 (0)