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 */