diff --git a/nifti2/nifti_tool.c b/nifti2/nifti_tool.c index ac249bf8..4af13d38 100644 --- a/nifti2/nifti_tool.c +++ b/nifti2/nifti_tool.c @@ -2284,6 +2284,7 @@ int act_add_exts( nt_opts * opts ) opts->etypes.list[ec]); if( nifti_add_extension(nim, ext, elen, opts->etypes.list[ec]) ){ + free(edata); /* may hold the file contents read just above */ nifti_image_free(nim); return 1; } diff --git a/niftilib/nifti1_tool.c b/niftilib/nifti1_tool.c index 15bb165a..c9344a7f 100644 --- a/niftilib/nifti1_tool.c +++ b/niftilib/nifti1_tool.c @@ -1865,6 +1865,7 @@ int act_add_exts( nt_opts * opts ) } if( nifti_add_extension(nim, ext, elen, opts->etypes.list[ec]) ){ + free(edata); /* may hold the file contents read just above */ nifti_image_free(nim); return 1; }