Commit 1d42b3ea authored by Alfred Klomp's avatar Alfred Klomp Committed by Manuel Pégourié-Gonnard
Browse files

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().
parent 1b4eda3a
...@@ -134,6 +134,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n ) ...@@ -134,6 +134,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n )
{ {
fclose( f ); fclose( f );
free( *buf ); free( *buf );
*buf = NULL;
return( -1 ); return( -1 );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment