Skip to content

Commit 16e48a8

Browse files
committed
Throw error if cwd goes missing
1 parent c87e39e commit 16e48a8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/file.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ namespace Sass {
5555
const size_t wd_len = 4096;
5656
#ifndef _WIN32
5757
char wd[wd_len];
58-
std::string cwd = getcwd(wd, wd_len);
58+
char* pwd = getcwd(wd, wd_len);
59+
if (pwd == NULL) throw Exception::OperationError("cwd gone missing");
60+
std::string cwd = pwd;
5961
#else
6062
wchar_t wd[wd_len];
61-
std::string cwd = wstring_to_string(_wgetcwd(wd, wd_len));
63+
wchar_t* pwd = _wgetcwd(wd, wd_len);
64+
if (pwd == NULL) throw Exception::OperationError("cwd gone missing");
65+
std::string cwd = wstring_to_string(pwd);
6266
//convert backslashes to forward slashes
6367
replace(cwd.begin(), cwd.end(), '\\', '/');
6468
#endif

0 commit comments

Comments
 (0)