libc: fix potential nil dereference in system() posix wrapper

Should also fix CID 155750.
This commit is contained in:
Giacomo Tesio 2017-01-18 22:06:28 +01:00
parent b05c21397e
commit d43be3861b
1 changed files with 2 additions and 0 deletions

View File

@ -37,6 +37,8 @@ system(const char *command)
// TODO: fix this http://man7.org/linux/man-pages/man3/system.3.html
while((w = wait()) && w->pid != pid)
free(w);
if(w == nil)
return -1;
if(w->msg[0] != 0){
s = strstr(w->msg, __POSIX_EXIT_PREFIX);
if(s){