Skip to content

Commit

Permalink
Don't crash if NULL is passed to mrb_close
Browse files Browse the repository at this point in the history
Sometimes it is very useful just return from mrb_close if NULL is
passed as mrb.  This is the same spirit of free(3), which just does
nothing if NULL is passed.
  • Loading branch information
tatsuhiro-t committed Sep 12, 2015
1 parent eb9bec1 commit a085c04
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/state.c
Expand Up @@ -234,6 +234,7 @@ mrb_free_context(mrb_state *mrb, struct mrb_context *c)
MRB_API void
mrb_close(mrb_state *mrb)
{
if (!mrb) return;
if (mrb->atexit_stack_len > 0) {
mrb_int i;
for (i = mrb->atexit_stack_len; i > 0; --i) {
Expand Down

0 comments on commit a085c04

Please sign in to comment.