From 158e54f071a3b2b41e6105fc3064ce8297fe532a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 25 Aug 2022 03:24:57 +0200 Subject: FileView: Close handles on error in constructor. --- c/data.h | 8 ++++++-- 1 file 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(MapViewOfFile(hm, FILE_MAP_ALL_ACCESS, 0, 0, 0)); - if (!view) + if (!view) { + CloseHandle(hm); throw Win32Error(); + } } ~FileView() -- cgit v1.2.3