prf handles zero-length allocations graceful

This commit is contained in:
Martin Willi
2008-10-29 14:12:54 +00:00
parent a64cc8f75f
commit f65ba4e978
+10 -3
View File
@@ -96,9 +96,16 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
*/
static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
{
chunk->ptr = malloc(length);
chunk->len = length;
this->public.get_bytes(&(this->public), length, chunk->ptr);
if (length)
{
chunk->ptr = malloc(length);
chunk->len = length;
get_bytes(this, length, chunk->ptr);
}
else
{
*chunk = chunk_empty;
}
}
/**