[buffer] Fail in _create() if we cannot pre-allocate the requested size
This commit is contained in:
parent
cd361ec9a1
commit
e87867cb88
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue