1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-23 15:01:00 +03:00

pem2der.c: fix double-free bug

Found with Clang's `scan-build` tool.

load_file() allocates memory to a char** parameter. It then tries to fread() a
file, and if that fails, frees the memory and returns to caller. However, the
char** is not reset to NULL, which causes a double-free error when the caller
later passes it to free().
This commit is contained in:
Alfred Klomp
2014-07-14 22:09:21 +02:00
committed by Manuel Pégourié-Gonnard
parent 1b4eda3af9
commit 1d42b3ea7e

View File

@ -134,6 +134,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n )
{
fclose( f );
free( *buf );
*buf = NULL;
return( -1 );
}