aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-25 03:24:57 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-25 03:24:57 +0200
commit158e54f071a3b2b41e6105fc3064ce8297fe532a (patch)
treede2664b6088849aa866dfca8fe84f83f0bbc8101
parent69fc595053d2075d6a7d99d94912156851a0221d (diff)
downloadEpisodeBrowser-158e54f071a3b2b41e6105fc3064ce8297fe532a.tar.gz
FileView: Close handles on error in constructor.
-rw-r--r--c/data.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/c/data.h b/c/data.h
index 7114440..4fbf3e4 100644
--- a/c/data.h
+++ b/c/data.h
@@ -117,12 +117,16 @@ struct FileView
cbMap.QuadPart = c*sizeof(T);
hm = CreateFileMapping(hf, nullptr, PAGE_READWRITE,
cbMap.HighPart, cbMap.LowPart, nullptr);
- if (!hm)
+ if (!hm) {
+ CloseHandle(hf);
throw Win32Error();
+ }
view = reinterpret_cast<T*>(MapViewOfFile(hm, FILE_MAP_ALL_ACCESS, 0, 0, 0));
- if (!view)
+ if (!view) {
+ CloseHandle(hm);
throw Win32Error();
+ }
}
~FileView()