Fix preprocessor hanging indefinitely when running #include on WSL (#735)

This commit is contained in:
James L. Walsh 2024-08-14 01:35:19 -07:00 committed by GitHub
parent 81b4a0243d
commit 6c04b63e10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 <assert.h>
#include <stdio.h>
#include <stdlib.h>
@ -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 */