ko1 / atdot.net wrote:
> 
> > +                if (newsize > INT_MAX) rb_memerror();
> 
> memerror?

I took the hint from compile_data_alloc:

    if (size >= INT_MAX) rb_memerror();
    if (storage->pos + size > storage->size) {
	unsigned int alloc_size = storage->size;

	while (alloc_size < size) {
	    if (alloc_size >= INT_MAX / 2) rb_memerror();
	    alloc_size *= 2;

Nobody hits the limit, so reusing rb_memerror keeps code size down.