@@ -75,8 +75,11 @@ typedef unsigned short mode_t;
75
75
#define DEFAULT_SLASH '\\'
76
76
#define DEFAULT_DIR_SEPARATOR ';'
77
77
#define IS_SLASH (c ) ((c) == '/' || (c) == '\\')
78
+ // IS_SLASH_P() may read the previous char on Windows, which may be OOB; use IS_SLASH_P_EX() instead
78
79
#define IS_SLASH_P (c ) (*(c) == '/' || \
79
80
(*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
81
+ #define IS_SLASH_P_EX (c , first_byte ) (*(c) == '/' || \
82
+ (*(c) == '\\' && ((first_byte) || !IsDBCSLeadByte(*(c-1)))))
80
83
81
84
/* COPY_WHEN_ABSOLUTE is 2 under Win32 because by chance both regular absolute paths
82
85
in the file system and UNC paths need copying of two characters */
@@ -110,7 +113,9 @@ typedef unsigned short mode_t;
110
113
#endif
111
114
112
115
#define IS_SLASH (c ) ((c) == '/')
116
+ // IS_SLASH_P() may read the previous char on Windows, which may be OOB; use IS_SLASH_P_EX() instead
113
117
#define IS_SLASH_P (c ) (*(c) == '/')
118
+ #define IS_SLASH_P_EX (c , first_byte ) IS_SLASH_P(c)
114
119
115
120
#endif
116
121
0 commit comments