Browse Source

Do not use _caca_alloc2d in the Ruby extension

main
Pascal Terjan 4 days ago
parent
commit
94517c520d
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      ruby/caca-canvas.c

+ 6
- 1
ruby/caca-canvas.c View File

@@ -586,7 +586,12 @@ static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VA
rb_raise(rb_eArgError, "First argument is not a Caca::Font");
}

buf = _caca_alloc2d(width, height, 4);
if (width == 0 || height == 0 || SIZE_MAX / width / height < 4)
{
rb_raise(rb_eRangeError, "width * height is too large");
}

buf = malloc(width * height * 4);
if(buf == NULL)
{
rb_raise(rb_eNoMemError, "Out of memory");


Loading…
Cancel
Save