[trunk] WIP: solve some memory leak in test compare functions
This commit is contained in:
parent
436318a8c8
commit
5b93ae8628
3
CHANGES
3
CHANGES
|
@ -5,6 +5,9 @@ What's New for OpenJPEG
|
|||
! : changed
|
||||
+ : added
|
||||
|
||||
October 19, 2011
|
||||
* [mickael] WIP: resolve some memory leak in compare functions
|
||||
|
||||
October 12, 2011
|
||||
* [mickael] WIP: resolve heap corruption with p0_07.j2k (credit to Winfried)
|
||||
* [mickael] WIP: correct some memory leaks in applications functions
|
||||
|
|
|
@ -321,7 +321,10 @@ double* parseToleranceValues( char* inArg, const int nbcomp)
|
|||
}
|
||||
|
||||
if (it_comp != nbcomp)
|
||||
{
|
||||
free(outArgs);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return outArgs;
|
||||
}
|
||||
|
@ -407,10 +410,21 @@ opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separ
|
|||
// Read the pgx file corresponding to the component
|
||||
image_read = pgxtoimage(filenameComponentPGX, ¶meters);
|
||||
if (!image_read)
|
||||
{
|
||||
fprintf(stderr, "Unable to load pgx file\n");
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
int it_free_data;
|
||||
fprintf(stderr, "Unable to load pgx file\n");
|
||||
|
||||
free(param_image_read);
|
||||
|
||||
for (it_free_data = 0; it_free_data < it_file; it_free_data++) {
|
||||
free(data[it_free_data]);
|
||||
}
|
||||
free(data);
|
||||
|
||||
free(filenameComponentPGX);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Set the image_read parameters
|
||||
param_image_read[it_file].x0 = 0;
|
||||
|
@ -498,10 +512,10 @@ int main(int argc, char **argv)
|
|||
if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE )
|
||||
{
|
||||
comparePGXimages_help_display();
|
||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (!inParam.base_filename) free(inParam.base_filename);
|
||||
if (!inParam.test_filename) free(inParam.test_filename);
|
||||
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (inParam.base_filename) free(inParam.base_filename);
|
||||
if (inParam.test_filename) free(inParam.test_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -560,10 +574,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (!inParam.base_filename) free(inParam.base_filename);
|
||||
if (!inParam.test_filename) free(inParam.test_filename);
|
||||
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (inParam.base_filename) free(inParam.base_filename);
|
||||
if (inParam.test_filename) free(inParam.test_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -582,10 +596,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (!inParam.base_filename) free(inParam.base_filename);
|
||||
if (!inParam.test_filename) free(inParam.test_filename);
|
||||
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||
if (inParam.base_filename) free(inParam.base_filename);
|
||||
if (inParam.test_filename) free(inParam.test_filename);
|
||||
free(filenamePNGbase);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -127,18 +127,52 @@ int main(int argc, char **argv)
|
|||
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
|
||||
{
|
||||
compareRAWimages_help_display();
|
||||
|
||||
/* Free Memory */
|
||||
if (inParam.base_filename){
|
||||
free(inParam.base_filename);
|
||||
inParam.base_filename = NULL;
|
||||
}
|
||||
if (inParam.test_filename){
|
||||
free(inParam.test_filename);
|
||||
inParam.test_filename = NULL;
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
file_test = fopen(inParam.test_filename, "rb");
|
||||
if (!file_test) {
|
||||
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
|
||||
|
||||
/* Free Memory */
|
||||
if (inParam.base_filename){
|
||||
free(inParam.base_filename);
|
||||
inParam.base_filename = NULL;
|
||||
}
|
||||
if (inParam.test_filename){
|
||||
free(inParam.test_filename);
|
||||
inParam.test_filename = NULL;
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
file_base = fopen(inParam.base_filename, "rb");
|
||||
if (!file_base) {
|
||||
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
|
||||
|
||||
/* Free Memory */
|
||||
if (inParam.base_filename){
|
||||
free(inParam.base_filename);
|
||||
inParam.base_filename = NULL;
|
||||
}
|
||||
if (inParam.test_filename){
|
||||
free(inParam.test_filename);
|
||||
inParam.test_filename = NULL;
|
||||
}
|
||||
|
||||
fclose(file_test);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -179,6 +213,16 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* Free Memory */
|
||||
if (inParam.base_filename){
|
||||
free(inParam.base_filename);
|
||||
inParam.base_filename = NULL;
|
||||
}
|
||||
if (inParam.test_filename){
|
||||
free(inParam.test_filename);
|
||||
inParam.test_filename = NULL;
|
||||
}
|
||||
|
||||
fclose(file_test);
|
||||
fclose(file_base);
|
||||
|
||||
|
|
Loading…
Reference in New Issue