[buffer] Fail in _create() if we cannot pre-allocate the requested size

This commit is contained in:
Behdad Esfahbod 2011-05-02 19:35:05 -04:00
parent cd361ec9a1
commit e87867cb88
1 changed files with 5 additions and 3 deletions

View File

@ -142,11 +142,13 @@ hb_buffer_create (unsigned int pre_alloc_size)
if (!(buffer = hb_object_create<hb_buffer_t> ()))
return &_hb_buffer_nil;
if (pre_alloc_size)
_hb_buffer_ensure (buffer, pre_alloc_size);
hb_buffer_reset (buffer);
if (pre_alloc_size && !_hb_buffer_ensure (buffer, pre_alloc_size)) {
hb_buffer_destroy (buffer);
return &_hb_buffer_nil;
}
return buffer;
}