state.c: check irep reference count overflow.

parent 5d371604
......@@ -4,6 +4,7 @@
** See Copyright Notice in mruby.h
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <mruby.h>
......@@ -110,6 +111,12 @@ void
mrb_irep_incref(mrb_state *mrb, mrb_irep *irep)
{
if (irep->flags & MRB_IREP_NO_FREE) return;
if (irep->refcnt == UINT16_MAX) {
mrb_garbage_collect(mrb);
if (irep->refcnt == UINT16_MAX) {
mrb_raise(mrb, E_RUNTIME_ERROR, "too many irep references");
}
}
irep->refcnt++;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment