Skip to content

Commit 3d51335

Browse files
committed
Make copy of RegContentMemory on open
1 parent 57d85e1 commit 3d51335

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/FileSystems/FileSystemMemory.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ class FileSystemMemory : public FileSystem {
169169
FS_LOGW("open: entry invalid: %s", path);
170170
return -1;
171171
}
172-
entry.content = mem_entry.content;
172+
// copy content, so that we can delete the entry.content when it is closed
173+
entry.content = new RegContentMemory();
174+
*entry.content = *mem_entry.content;
173175
return entry.fileID;
174176
}
175177

src/FileSystems/Registry.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct RegEntry {
9090
RegEntry() = default;
9191
~RegEntry() {
9292
if (content != nullptr) {
93+
FS_LOGD("~RegEntry: %s", file_name);
9394
delete content;
9495
content = nullptr;
9596
}
@@ -193,9 +194,6 @@ class Registry {
193194
FS_TRACED();
194195
RegEntry *p_entry = open_files[fileID];
195196
if (p_entry != nullptr) {
196-
if (p_entry->content != nullptr) {
197-
delete p_entry->content;
198-
}
199197
delete p_entry;
200198
open_files[fileID] = nullptr;
201199
}

0 commit comments

Comments
 (0)