Skip to content

Commit

Permalink
Fix possible uninitialized read on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ISSOtm committed Aug 31, 2020
1 parent df77693 commit 7f3b0be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/asm/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,16 @@ static void initState(struct LexerState *state)
# include <winbase.h>
# define MAP_FAILED NULL
# define mapFile(ptr, fd, path, size) do { \
(ptr) = MAP_FAILED; \
HANDLE file = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, \
FILE_FLAG_POSIX_SEMANTICS | FILE_FLAG_RANDOM_ACCESS, NULL); \
HANDLE mappingObj; \
\
if (file == INVALID_HANDLE_VALUE) \
break; \
mappingObj = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL); \
(ptr) = mappingObj == INVALID_HANDLE_VALUE \
? NULL \
: MapViewOfFile(mappingObj, FILE_MAP_READ, 0, 0, 0); \
if (mappingObj != INVALID_HANDLE_VALUE) \
(ptr) = MapViewOfFile(mappingObj, FILE_MAP_READ, 0, 0, 0); \
CloseHandle(mappingObj); \
CloseHandle(file); \
} while (0)
Expand Down

0 comments on commit 7f3b0be

Please sign in to comment.