Skip to content

Commit

Permalink
Bug Fix: Freeing Array Structure If Out of Memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Theldus committed Apr 25, 2020
1 parent 72bd326 commit e164cdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ int array_init(struct array **array)
out->elements = 0;
out->buf = calloc(out->capacity, sizeof(void *));
if (out->buf == NULL)
{
free(out);
return (-1);
}

*array = out;
return (0);
Expand Down

0 comments on commit e164cdb

Please sign in to comment.