mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
state.c: check irep reference count overflow.
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user