Skip to content

Commit 43e3ff9

Browse files
mirkodziadzka-aviFelipe Zimmerle
authored and
Felipe Zimmerle
committed
Fixes a bug with an unitialized variable.
new_debug_log was unitialized during an error code path. Fixed this by explicit initializing it to NULL and fixing the order of the error labels. They now present the correct (reverse) order of the goto statements.
1 parent 3a048ee commit 43e3ff9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utils/shared_files.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ std::pair<msc_file_handler *, FILE *> SharedFiles::add_new_handler(
5252
int shm_id;
5353
int ret;
5454
key_t mem_key_structure;
55-
msc_file_handler_t *new_debug_log;
55+
msc_file_handler_t *new_debug_log = NULL;
5656
struct shmid_ds shared_mem_info;
5757
FILE *fp;
5858
bool toBeCreated = true;
@@ -113,10 +113,10 @@ std::pair<msc_file_handler *, FILE *> SharedFiles::add_new_handler(
113113
std::make_pair(new_debug_log, fp)));
114114

115115
return std::make_pair(new_debug_log, fp);
116-
err_shmget1:
117-
err_shmctl1:
118116
err_shmat1:
119117
shmdt(new_debug_log);
118+
err_shmctl1:
119+
err_shmget1:
120120
err_mem_key:
121121
fclose(fp);
122122
err_fh:

0 commit comments

Comments
 (0)