Skip to content

Commit f4639eb

Browse files
committed
fix potentially sketchy use of stale pointer
credit to @lisanet refs: https://github.com/benfry/atomicparsley/pull/1
1 parent 84d1ee0 commit f4639eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ ISO Base Media File; store the resulting FILE* in a global source_file
122122
FILE *APar_OpenISOBaseMediaFile(const char *utf8file, bool open) {
123123
if (open && !file_opened) {
124124
source_file = APar_OpenFile(utf8file, "rb");
125-
if (source_file != NULL) {
125+
if (source_file != nullptr) {
126126
file_opened = true;
127127
}
128-
} else {
128+
} else if (file_opened) {
129129
fclose(source_file);
130130
file_opened = false;
131+
source_file = nullptr;
131132
}
132133
return source_file;
133134
}

0 commit comments

Comments
 (0)