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:
parent
1b4eda3af9
commit
1d42b3ea7e
@ -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 );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user