Avoiding a potential memory leak in xorriso main()
This commit is contained in:
parent
81d0d30cb8
commit
3000c539d7
@ -20077,6 +20077,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
struct XorrisO *xorriso= NULL;
|
struct XorrisO *xorriso= NULL;
|
||||||
|
char **orig_argv= NULL;
|
||||||
|
|
||||||
if(strcmp(Xorriso_main_program_versioN, Xorriso_program_versioN)) {
|
if(strcmp(Xorriso_main_program_versioN, Xorriso_program_versioN)) {
|
||||||
yell_xorriso();
|
yell_xorriso();
|
||||||
@ -20131,6 +20132,7 @@ int main(int argc, char **argv)
|
|||||||
exit(5);
|
exit(5);
|
||||||
|
|
||||||
/* Interpret program arguments */
|
/* Interpret program arguments */
|
||||||
|
orig_argv= argv;
|
||||||
ret= Xorriso_program_arg_bsl(xorriso, argc, &argv, 0);
|
ret= Xorriso_program_arg_bsl(xorriso, argc, &argv, 0);
|
||||||
if(ret <= 0)
|
if(ret <= 0)
|
||||||
exit(5);
|
exit(5);
|
||||||
@ -20154,6 +20156,12 @@ end_sucessfully:;
|
|||||||
ret= Xorriso_make_return_value(xorriso, 0);
|
ret= Xorriso_make_return_value(xorriso, 0);
|
||||||
Xorriso_process_errfile(xorriso, 0, "xorriso end", 0, 1);
|
Xorriso_process_errfile(xorriso, 0, "xorriso end", 0, 1);
|
||||||
Xorriso_destroy(&xorriso, 1);
|
Xorriso_destroy(&xorriso, 1);
|
||||||
|
if(orig_argv != argv && orig_argv != NULL) {
|
||||||
|
for(i= 0; i < argc; i++)
|
||||||
|
if(argv[i] != NULL)
|
||||||
|
free(argv[i]);
|
||||||
|
free(argv);
|
||||||
|
}
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,14 @@ char *Xorriso__get_version_text(int flag);
|
|||||||
@param progname typically argv[0] of main(). Some leafnames of the progname
|
@param progname typically argv[0] of main(). Some leafnames of the progname
|
||||||
path have special meaning and trigger special behavior:
|
path have special meaning and trigger special behavior:
|
||||||
"osirrox" allows image-to-disk copying: -osirrox "on"
|
"osirrox" allows image-to-disk copying: -osirrox "on"
|
||||||
"xorrisofs" activates permanent mkisofs emulation
|
"xorrisofs" activates -as "mkisofs" emulation from start
|
||||||
"genisofs" alias of "xorrisofs"
|
"genisofs" alias of "xorrisofs"
|
||||||
"mkisofs" alias of "xorrisofs"
|
"mkisofs" alias of "xorrisofs"
|
||||||
"genisoimage" alias of "xorrisofs"
|
"genisoimage" alias of "xorrisofs"
|
||||||
|
"xorrecord" activates -as "cdrecord" emulation from start
|
||||||
|
"cdrecord" alias of "xorrecord"
|
||||||
|
"wodim" alias of "xorrecord"
|
||||||
|
"cdrskin" alias of "xorrecord"
|
||||||
@param flag unused yet, submit 0
|
@param flag unused yet, submit 0
|
||||||
@return >0 success , <=0 failure, no object created
|
@return >0 success , <=0 failure, no object created
|
||||||
*/
|
*/
|
||||||
@ -102,6 +106,12 @@ int Xorriso_read_rc(struct XorrisO *xorriso, int flag);
|
|||||||
@param argc Number of arguments.
|
@param argc Number of arguments.
|
||||||
@param argv The arguments. (*argv)[0] contains the program name.
|
@param argv The arguments. (*argv)[0] contains the program name.
|
||||||
(*argv)[1] to (*argv)[argc-1] contain commands and parameters
|
(*argv)[1] to (*argv)[argc-1] contain commands and parameters
|
||||||
|
If argv after the call differs from argv before the call,
|
||||||
|
then one should dispose it later by:
|
||||||
|
for(i= 0; i < argc; i++)
|
||||||
|
if(argv[i] != NULL)
|
||||||
|
free(argv[i]);
|
||||||
|
free(argv);
|
||||||
@param flag unused yet, submit 0
|
@param flag unused yet, submit 0
|
||||||
@return <= 0 error , > 0 success
|
@return <= 0 error , > 0 success
|
||||||
*/
|
*/
|
||||||
@ -258,8 +268,7 @@ int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity,
|
|||||||
|
|
||||||
|
|
||||||
/* The next two functions are part of Xorriso_eval_problem_status().
|
/* The next two functions are part of Xorriso_eval_problem_status().
|
||||||
You may use them to build an own advisor function or to drain the
|
You may use them to build an own advisor function.
|
||||||
library message queues more frequently.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Obtain the current problem status of the xorriso handle.
|
/** Obtain the current problem status of the xorriso handle.
|
||||||
@ -277,7 +286,10 @@ int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80],
|
|||||||
the severity of the library events like the severity of a message submitted
|
the severity of the library events like the severity of a message submitted
|
||||||
via Xorriso_msgs_submit().
|
via Xorriso_msgs_submit().
|
||||||
xorriso sets the message queues of the libraries to queuing "ALL".
|
xorriso sets the message queues of the libraries to queuing "ALL".
|
||||||
So it is essential that they get drained regularly.
|
Many inner functions of xorriso call Xorriso_process_msg_queues() on their
|
||||||
|
own because they expect library output pending. Nevertheless, a loop of
|
||||||
|
xorriso option calls should either call Xorriso_eval_problem_status() or
|
||||||
|
Xorriso_process_msg_queues() with each cycle.
|
||||||
@param xorriso The environment handle
|
@param xorriso The environment handle
|
||||||
@param flag Unused yet. Submit 0.
|
@param flag Unused yet. Submit 0.
|
||||||
@return 1 on success, <=0 if failure
|
@return 1 on success, <=0 if failure
|
||||||
|
@ -1 +1 @@
|
|||||||
#define Xorriso_timestamP "2009.09.13.095136"
|
#define Xorriso_timestamP "2009.09.16.162424"
|
||||||
|
Loading…
Reference in New Issue
Block a user