Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard calling fclose() on NULL rio-f.
Browse files Browse the repository at this point in the history
brixen committed Jul 11, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f7665ae commit 88f794e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions machine/capi/io.cpp
Original file line number Diff line number Diff line change
@@ -128,8 +128,15 @@ namespace rubinius {

if(rio->finalize) rio->finalize(rio, true);

bool ok = (fclose(rio->f) == 0);
rio->f = NULL;
bool ok = true;

/* This field is publicly accessible in the C-API structure so we need
* to guard against the possibility that it is NULL;
*/
if(rio->f) {
ok = (fclose(rio->f) == 0);
rio->f = NULL;
}

return ok;
}

0 comments on commit 88f794e

Please sign in to comment.