mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-12 23:27:15 +03:00
fix potential memory leak if the second malloc fails
This commit is contained in:
parent
ee48dae8c5
commit
db4ae0ef9d
5
gap.c
5
gap.c
@ -48,7 +48,10 @@ gap_array* gap_init(int len)
|
|||||||
gap->len = gap_len_alloc(elem_size);
|
gap->len = gap_len_alloc(elem_size);
|
||||||
if (gap->len < len) gap->len = len;
|
if (gap->len < len) gap->len = len;
|
||||||
gap->array = malloc(gap->len * elem_size);
|
gap->array = malloc(gap->len * elem_size);
|
||||||
if (!gap->array) return NULL;
|
if (!gap->array) {
|
||||||
|
free(gap);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < gap->len; i++)
|
for (int i = 0; i < gap->len; i++)
|
||||||
gap->array[i] = NULL;
|
gap->array[i] = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user