Revert "Free the original pointer if realloc failed."

This reverts commit 9cdf439db5.
This commit is contained in:
Hiroshi Mimaki
2020-06-30 18:33:47 +09:00
parent ac8360003e
commit aa578c346d
+8 -3
View File
@@ -225,9 +225,14 @@ mrb_realloc(mrb_state *mrb, void *p, size_t len)
p2 = mrb_realloc_simple(mrb, p, len);
if (len == 0) return p2;
if (p2 == NULL) {
mrb_free(mrb, p);
mrb->gc.out_of_memory = TRUE;
mrb_raise_nomemory(mrb);
if (mrb->gc.out_of_memory) {
mrb_raise_nomemory(mrb);
/* mrb_panic(mrb); */
}
else {
mrb->gc.out_of_memory = TRUE;
mrb_raise_nomemory(mrb);
}
}
else {
mrb->gc.out_of_memory = FALSE;