Skip to content

Commit

Permalink
don't crash on reading a closed dir handle
Browse files Browse the repository at this point in the history
Fixes RT #131301

Not sure if a change for windows is needed, as it already checks
for invalid handle values.
  • Loading branch information
timo committed May 13, 2017
1 parent 6d5ea04 commit 22fb8e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/io/dirops.c
Expand Up @@ -322,6 +322,10 @@ MVMString * MVM_dir_read(MVMThreadContext *tc, MVMObject *oshandle) {
struct dirent *entry;
errno = 0; /* must reset errno so we won't check old errno */

if (!data->dir_handle) {
MVM_exception_throw_adhoc(tc, "Cannot read a closed dir handle.");
}

entry = readdir(data->dir_handle);

if (errno == 0) {
Expand Down

0 comments on commit 22fb8e4

Please sign in to comment.