Check error code in rust_file_is_dir. Prevent comparison of uninitialized mem

This commit is contained in:
Brian Anderson 2011-09-01 12:38:36 -07:00
parent 4951bb8bfc
commit baa1e8790d
2 changed files with 8 additions and 1 deletions

View file

@ -446,7 +446,9 @@ rust_dirent_filename(rust_task *task, dirent* ent) {
extern "C" CDECL int
rust_file_is_dir(rust_task *task, rust_str *path) {
struct stat buf;
stat((char*)path->data, &buf);
if (stat((char*)path->data, &buf)) {
return 0;
}
return S_ISDIR(buf.st_mode);
}