Skip to content

Commit cb13dfe

Browse files
authored
Merge pull request #524 from uyjulian/cwd_nullpo_check
Check if slash or colon is found before accessing CWD
2 parents fa86186 + 37ebc3a commit cb13dfe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ee/libcglue/src/cwd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,18 @@ void __init_cwd(int argc, char ** argv)
217217
return;
218218
}
219219

220-
char * p, * s = 0;
220+
char * p, * s = NULL;
221221
// let's find the last slash, or at worst, the :
222222
for (p = argv[0]; *p; p++) {
223223
if ((*p == '/') || (*p == '\\') || (*p == ':')) {
224224
s = p;
225225
}
226226
}
227+
if (s == NULL)
228+
{
229+
chdir("host:");
230+
return;
231+
}
227232
char backup = *(++s);
228233
*s = 0;
229234
chdir(argv[0]);

0 commit comments

Comments
 (0)