On Tue, 2020-06-16 at 12:52 +0300, Aaro Altonen wrote:
if (i == connpoint->sinks_size)
{
connpoint->sinks_size *= 2;
connpoint->sinks = heap_realloc_zero( connpoint->sinks,
connpoint->sinks_size * sizeof(*connpoint->sinks) );
if (!connpoint->sinks) return E_OUTOFMEMORY;
}
If heap_realloc_zero fails this leaks the original allocation and leaves the object in an inconsistent state. You can use temporary variables to make this a transaction, like it's done in resize_fields.