Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nifti2/nifti_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ int act_diff_nims( nt_opts * opts )
if( ! nim0 ) return 1; /* errors have been printed */

nim1 = nt_image_read(opts, opts->infiles.list[1], 0, 0);
if( ! nim1 ){ free(nim0); return 1; }
if( ! nim1 ){ nifti_image_free(nim0); return 1; }

if( g_debug > 1 )
fprintf(stderr,"\n-d nifti_image diffs between '%s' and '%s'...\n",
Expand Down Expand Up @@ -3359,6 +3359,7 @@ int act_mod_hdrs( nt_opts * opts )
if( !nim ) {
fprintf(stderr,"** failed to dup file '%s' before modifying\n",
fname);
free(nhdr);
return 1;
}

Expand All @@ -3369,6 +3370,7 @@ int act_mod_hdrs( nt_opts * opts )
{
NTL_FERR(func,"failed to set prefix for new file: ",opts->prefix);
nifti_image_free(nim);
free(nhdr);
return 1;
}
dupname = nifti_strdup(nim->fname); /* so we know to free it */
Expand All @@ -3377,6 +3379,8 @@ int act_mod_hdrs( nt_opts * opts )
if( nifti_image_write_status(nim) ) {
fprintf(stderr,"** failed to write image %s\n", nim->fname);
nifti_image_free(nim);
free(dupname);
free(nhdr);
return 1;
}

Expand Down Expand Up @@ -3477,6 +3481,7 @@ int act_mod_hdr2s( nt_opts * opts )
if( !nim ) {
fprintf(stderr,"** failed to dup file '%s' before modifying\n",
fname);
free(nhdr);
return 1;
}
if( opts->keep_hist && nifti_add_extension(nim, opts->command,
Expand All @@ -3486,6 +3491,7 @@ int act_mod_hdr2s( nt_opts * opts )
{
NTL_FERR(func,"failed to set prefix for new file: ",opts->prefix);
nifti_image_free(nim);
free(nhdr);
return 1;
}
dupname = nifti_strdup(nim->fname); /* so we know to free it */
Expand All @@ -3494,6 +3500,8 @@ int act_mod_hdr2s( nt_opts * opts )
if( nifti_image_write_status(nim) ) {
fprintf(stderr,"** failed to write image %s\n", nim->fname);
nifti_image_free(nim);
free(dupname);
free(nhdr);
return 1;
}

Expand Down Expand Up @@ -3623,6 +3631,7 @@ int act_swap_hdrs( nt_opts * opts )
if( !nim ) {
fprintf(stderr,"** failed to dup file '%s' before modifying\n",
fname);
free(nhdr);
return 1;
}
if( opts->keep_hist && nifti_add_extension(nim, opts->command,
Expand All @@ -3632,6 +3641,7 @@ int act_swap_hdrs( nt_opts * opts )
{
NTL_FERR(func,"failed to set prefix for new file: ",opts->prefix);
nifti_image_free(nim);
free(nhdr);
return 1;
}
dupname = nifti_strdup(nim->fname); /* so we know to free it */
Expand All @@ -3640,6 +3650,8 @@ int act_swap_hdrs( nt_opts * opts )
if( nifti_image_write_status(nim) ) {
fprintf(stderr,"** failed to write image %s\n", nim->fname);
nifti_image_free(nim);
free(dupname);
free(nhdr);
return 1;
}

Expand Down
10 changes: 9 additions & 1 deletion niftilib/nifti1_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,7 @@ int act_diff_nims( nt_opts * opts )
if( ! nim0 ) return 1; /* errors have been printed */

nim1 = nt_image_read(opts, opts->infiles.list[1], 0);
if( ! nim1 ){ free(nim0); return 1; }
if( ! nim1 ){ nifti_image_free(nim0); return 1; }

if( g_debug > 1 )
fprintf(stderr,"\n-d nifti_image diffs between '%s' and '%s'...\n",
Expand Down Expand Up @@ -2606,6 +2606,7 @@ int act_mod_hdrs( nt_opts * opts )
if( !nim ) {
fprintf(stderr,"** failed to dup file '%s' before modifying\n",
fname);
free(nhdr);
return 1;
}
if( opts->keep_hist && nifti_add_extension(nim, opts->command,
Expand All @@ -2615,6 +2616,7 @@ int act_mod_hdrs( nt_opts * opts )
{
NTL_FERR(func,"failed to set prefix for new file: ",opts->prefix);
nifti_image_free(nim);
free(nhdr);
return 1;
}
dupname = nifti_strdup(nim->fname); /* so we know to free it */
Expand All @@ -2623,6 +2625,8 @@ int act_mod_hdrs( nt_opts * opts )
if( nifti_image_write_status(nim) ) {
fprintf(stderr,"** failed to write image %s\n", nim->fname);
nifti_image_free(nim);
free(dupname);
free(nhdr);
return 1;
}

Expand Down Expand Up @@ -2727,6 +2731,7 @@ int act_swap_hdrs( nt_opts * opts )
if( !nim ) {
fprintf(stderr,"** failed to dup file '%s' before modifying\n",
fname);
free(nhdr);
return 1;
}
if( opts->keep_hist && nifti_add_extension(nim, opts->command,
Expand All @@ -2736,6 +2741,7 @@ int act_swap_hdrs( nt_opts * opts )
{
NTL_FERR(func,"failed to set prefix for new file: ",opts->prefix);
nifti_image_free(nim);
free(nhdr);
return 1;
}
dupname = nifti_strdup(nim->fname); /* so we know to free it */
Expand All @@ -2744,6 +2750,8 @@ int act_swap_hdrs( nt_opts * opts )
if( nifti_image_write_status(nim) ) {
fprintf(stderr,"** failed to write image %s\n", nim->fname);
nifti_image_free(nim);
free(dupname);
free(nhdr);
return 1;
}

Expand Down
Loading