prf-plus: Fix a potential memory leak if get_bytes() fails

This commit is contained in:
Tobias Brunner
2019-10-21 12:22:22 +02:00
parent 1b96e4a465
commit c75010080a
+4 -4
View File
@@ -103,12 +103,12 @@ METHOD(prf_plus_t, get_bytes, bool,
METHOD(prf_plus_t, allocate_bytes, bool, METHOD(prf_plus_t, allocate_bytes, bool,
private_prf_plus_t *this, size_t length, chunk_t *chunk) private_prf_plus_t *this, size_t length, chunk_t *chunk)
{ {
if (length) *chunk = chunk_alloc(length);
if (!get_bytes(this, length, chunk->ptr))
{ {
*chunk = chunk_alloc(length); chunk_free(chunk);
return get_bytes(this, length, chunk->ptr); return FALSE;
} }
*chunk = chunk_empty;
return TRUE; return TRUE;
} }