This patch fixes some undefined behaviour in the argument parser. Previously, it was possible for the application to encounter a segmentation fault due to the *argv pointer floating into invalid memory. It also avoids segmentation faults from passing zero arguments.
The parser has been simplified to accept a single operation per program invocation, and as a consequence it no longer plays with pointer incrementation to operate!
I also shifted the ps3mca initialisation code into a function (mirroring close_ps3mca) and made it the responsibility of each individual operation's function to call it, and close_ps3mca. This means you don't have to wait for the ps3mca to be initialised (possibly failing in the process!) in order to get output from the argument parser.
This patch fixes some undefined behaviour in the argument parser. Previously, it was possible for the application to encounter a segmentation fault due to the
*argv
pointer floating into invalid memory. It also avoids segmentation faults from passing zero arguments.The parser has been simplified to accept a single operation per program invocation, and as a consequence it no longer plays with pointer incrementation to operate!
I also shifted the ps3mca initialisation code into a function (mirroring
close_ps3mca
) and made it the responsibility of each individual operation's function to call it, andclose_ps3mca
. This means you don't have to wait for the ps3mca to be initialised (possibly failing in the process!) in order to get output from the argument parser.