diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-03-13 20:30:32 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-03-13 20:30:32 -0700 |
| commit | 6f9cd0b90356f6edf68add84671c5be2e92a7b52 (patch) | |
| tree | cb7aa27af7a944d342383811d3798309b2745813 /src | |
| parent | c9f3fd477912fa4a822f750fc15df77841828d44 (diff) | |
| parent | 718a748799f896e6dc943494e3e7a66a48cb8d30 (diff) | |
| download | mruby-6f9cd0b90356f6edf68add84671c5be2e92a7b52.tar.gz mruby-6f9cd0b90356f6edf68add84671c5be2e92a7b52.zip | |
Merge pull request #1003 from kano4/pr-add-null-check
Add null check
Diffstat (limited to 'src')
| -rw-r--r-- | src/state.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/state.c b/src/state.c index b6805a4a4..efb6d66b1 100644 --- a/src/state.c +++ b/src/state.c @@ -53,6 +53,7 @@ mrb_alloca(mrb_state *mrb, size_t size) struct alloca_header *p; p = (struct alloca_header*) mrb_malloc(mrb, sizeof(struct alloca_header)+size); + if (p == NULL) return NULL; p->next = mrb->mems; mrb->mems = p; return (void*)p->buf; @@ -61,9 +62,12 @@ mrb_alloca(mrb_state *mrb, size_t size) static void mrb_alloca_free(mrb_state *mrb) { - struct alloca_header *p = mrb->mems; + struct alloca_header *p; struct alloca_header *tmp; + if (mrb == NULL) return NULL; + p = mrb->mems; + while (p) { tmp = p; p = p->next; |
