From 6c04b63e104b709832af115d9e37e1c0a7382cf3 Mon Sep 17 00:00:00 2001 From: "James L. Walsh" Date: Wed, 14 Aug 2024 01:35:19 -0700 Subject: [PATCH] Fix preprocessor hanging indefinitely when running #include on WSL (#735) --- source/compiler/sc2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index ad4cb4b..3a0b890 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -21,6 +21,9 @@ * Version: $Id: sc2.c 3655 2006-10-23 20:17:52Z thiadmer $ */ +// Ensures stat() does not overflow when running on 64 bit systems +#define _FILE_OFFSET_BITS 64 + #include #include #include @@ -170,8 +173,8 @@ SC_FUNC int plungequalifiedfile(char *name) *ptr=DIRSEP_CHAR; } #endif - stat(real_path, &st); - if (!S_ISDIR(st.st_mode)) /* ignore directories with the same name */ + int sr = stat(real_path, &st); + if (sr == 0 && !S_ISDIR(st.st_mode)) /* ignore directories with the same name */ fp=(FILE*)pc_opensrc(real_path); if (fp==NULL) { *ext='\0'; /* on failure, restore filename */