Skip to content

Commit

Permalink
Fix success path memory leaks (#49)
Browse files Browse the repository at this point in the history
Errors still expected on the failure path, but this is a harder
one to fix with the current code, so not part of this commit
  • Loading branch information
Pete Harris committed Jul 5, 2019
1 parent efaffdb commit 62fadfc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Source/astc_toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2352,11 +2352,6 @@ int astc_main(int argc, char **argv)
printf("3D source images not supported with -array option: %s\n", new_input_filename);
exit(1);
}

// BCJ(DEBUG)
// printf("\n\n Image %d \n", image_index);
// dump_image( input_images[image_index] );
// printf("\n\n");
}

// Check load result.
Expand Down Expand Up @@ -2414,15 +2409,17 @@ int astc_main(int argc, char **argv)
{
destroy_image(input_images[i]);
}
input_images = NULL;

// Clamp texels outside the actual image area.
fill_image_padding_area(input_image);

// BCJ(DEBUG)
// dump_image( input_image );
}

delete[] input_images;
input_images = NULL;

delete[] load_results;
load_results = NULL;

input_components = load_result & 7;
input_image_is_hdr = (load_result & 0x80) ? 1 : 0;

Expand Down Expand Up @@ -2511,11 +2508,13 @@ int astc_main(int argc, char **argv)
}
}
}

if (opmode == 0)
{
store_astc_file(input_image, output_filename, xdim, ydim, zdim, &ewp, decode_mode, swz_encode, thread_count);
}

destroy_image(input_image);

if (print_block_mode_histogram)
{
Expand Down

0 comments on commit 62fadfc

Please sign in to comment.