Summary:
Off-by-one error in DIR::open() would result in paths not
ending in a trailing separator to fail to open. Fix the arithmetic.
Reviewed By: Orvid
Differential Revision:
D5579657
fbshipit-source-id:
79507bc398549033eb26b2ffa788d66241deb623
wchar_t patternBuf[MAX_PATH + 3];
size_t len;
+ if (pattern.empty()) {
+ return nullptr;
+ }
+
if (mbstowcs_s(&len, patternBuf, MAX_PATH, pattern.c_str(), MAX_PATH - 2)) {
return nullptr;
}
+ // `len` includes the trailing NUL
+ if (len) {
+ len--;
+ }
if (len && patternBuf[len - 1] != '/' && patternBuf[len - 1] != '\\') {
patternBuf[len++] = '\\';
}