Closed more memory leaks with demo/demo -iso_modify. Coverity CID 12558.
This commit is contained in:
parent
d51b1738dd
commit
4838cd59a7
50
demo/demo.c
50
demo/demo.c
@ -670,14 +670,14 @@ void iso_modify_usage(char **argv)
|
|||||||
|
|
||||||
int gesture_iso_modify(int argc, char **argv)
|
int gesture_iso_modify(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int result;
|
int result, return_val = 1, initialized = 0;
|
||||||
IsoImage *image;
|
IsoImage *image = NULL;
|
||||||
IsoDataSource *src = NULL;
|
IsoDataSource *src = NULL;
|
||||||
struct burn_source *burn_src;
|
struct burn_source *burn_src = NULL;
|
||||||
unsigned char buf[2048];
|
unsigned char buf[2048];
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
IsoWriteOpts *opts;
|
IsoWriteOpts *opts = NULL;
|
||||||
IsoReadOpts *ropts;
|
IsoReadOpts *ropts = NULL;
|
||||||
|
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
iso_modify_usage(argv);
|
iso_modify_usage(argv);
|
||||||
@ -690,7 +690,12 @@ int gesture_iso_modify(int argc, char **argv)
|
|||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
iso_init();
|
result = iso_init();
|
||||||
|
if (result < 0) {
|
||||||
|
demo_report_iso_err(result, "Cannot init libisofs");
|
||||||
|
goto ex;
|
||||||
|
}
|
||||||
|
initialized = 1;
|
||||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||||
|
|
||||||
/* create the data source to accesss previous image */
|
/* create the data source to accesss previous image */
|
||||||
@ -716,13 +721,15 @@ int gesture_iso_modify(int argc, char **argv)
|
|||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
result = iso_image_import(image, src, ropts, NULL);
|
result = iso_image_import(image, src, ropts, NULL);
|
||||||
iso_read_opts_free(ropts);
|
|
||||||
iso_data_source_unref(src);
|
|
||||||
src = NULL;
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
demo_report_iso_err(result, "Error importing previous session");
|
demo_report_iso_err(result, "Error importing previous session");
|
||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
|
/* (One could of course keep them alive until cleanup) */
|
||||||
|
iso_read_opts_free(ropts);
|
||||||
|
ropts = NULL;
|
||||||
|
iso_data_source_unref(src);
|
||||||
|
src = NULL;
|
||||||
|
|
||||||
/* add new dir */
|
/* add new dir */
|
||||||
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[2]);
|
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[2]);
|
||||||
@ -749,8 +756,8 @@ int gesture_iso_modify(int argc, char **argv)
|
|||||||
demo_report_iso_err(result, "Cannot create image object");
|
demo_report_iso_err(result, "Cannot create image object");
|
||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
iso_write_opts_free(opts);
|
iso_write_opts_free(opts);
|
||||||
|
opts = NULL;
|
||||||
|
|
||||||
while (burn_src->read_xt(burn_src, buf, 2048) == 2048) {
|
while (burn_src->read_xt(burn_src, buf, 2048) == 2048) {
|
||||||
result = fwrite(buf, 1, 2048, fp);
|
result = fwrite(buf, 1, 2048, fp);
|
||||||
@ -759,19 +766,26 @@ int gesture_iso_modify(int argc, char **argv)
|
|||||||
goto ex;
|
goto ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
|
||||||
burn_src->free_data(burn_src);
|
return_val = 0;
|
||||||
free(burn_src);
|
|
||||||
|
|
||||||
iso_image_unref(image);
|
|
||||||
iso_finish();
|
|
||||||
return 0;
|
|
||||||
ex:
|
ex:
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
if (opts != NULL)
|
||||||
|
iso_write_opts_free(opts);
|
||||||
|
if (burn_src != NULL) {
|
||||||
|
burn_src->free_data(burn_src);
|
||||||
|
free(burn_src);
|
||||||
|
}
|
||||||
|
if (image != NULL)
|
||||||
|
iso_image_unref(image);
|
||||||
|
if (ropts != NULL)
|
||||||
|
iso_read_opts_free(ropts);
|
||||||
if (src != NULL)
|
if (src != NULL)
|
||||||
iso_data_source_unref(src);
|
iso_data_source_unref(src);
|
||||||
return 1;
|
if (initialized)
|
||||||
|
iso_finish();
|
||||||
|
return return_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user