close file and file mapping handles

This commit is contained in:
olszomal 2023-01-11 15:04:31 +01:00 committed by Michał Trojnara
parent efbe570f27
commit c197d7727c

View File

@ -4865,10 +4865,12 @@ static char *map_file(const char *infile, const size_t size)
return NULL; return NULL;
} }
fmap = CreateFileMapping(fhandle, NULL, PAGE_READONLY, 0, 0, NULL); fmap = CreateFileMapping(fhandle, NULL, PAGE_READONLY, 0, 0, NULL);
CloseHandle(fhandle);
if (fmap == NULL) { if (fmap == NULL) {
return NULL; return NULL;
} }
indata = (char *)MapViewOfFile(fmap, FILE_MAP_READ, 0, 0, 0); indata = (char *)MapViewOfFile(fmap, FILE_MAP_READ, 0, 0, 0);
CloseHandle(fmap);
#else #else
int fd = open(infile, O_RDONLY); int fd = open(infile, O_RDONLY);
if (fd < 0) { if (fd < 0) {
@ -5076,6 +5078,7 @@ static int read_password(GLOBAL_OPTIONS *options)
return 0; /* FAILED */ return 0; /* FAILED */
} }
faddress = MapViewOfFile(fmap, FILE_MAP_READ, 0, 0, 0); faddress = MapViewOfFile(fmap, FILE_MAP_READ, 0, 0, 0);
CloseHandle(fmap);
if (faddress == NULL) { if (faddress == NULL) {
return 0; /* FAILED */ return 0; /* FAILED */
} }