[tools] mcd_pcm.c: Fixed some out_filename issues.
authorDavid Korth <gerbilsoft@gerbilsoft.com>
Sat, 5 Sep 2015 01:34:53 +0000 (21:34 -0400)
committerDavid Korth <gerbilsoft@gerbilsoft.com>
Sat, 5 Sep 2015 01:34:53 +0000 (21:34 -0400)
- Specify &out_filename in the poptOption array.
- strdup() the filename to prevent memory allocation issues.

src/tools/mcd_pcm.c

index a0e72c5..66fc8f0 100644 (file)
@@ -355,7 +355,7 @@ int main(int argc, char *argv[])
                        "Maximum length to dump, in bytes. (default = entire file)", "LEN"},
                {"rate",   'r', POPT_ARG_INT, (int*)&sample_rate, 0,
                        "Sample rate. (default = 32552 Hz)", "RATE"},
-               {"output", 'o', POPT_ARG_STRING, out_filename, 0,
+               {"output", 'o', POPT_ARG_STRING, &out_filename, 0,
                        "Output filename. (default = pcm_file.wav)", "FILENAME"},
                {NULL, 0, POPT_ARG_INCLUDE_TABLE, helpOptionsTable, 0,
                        "Help options:", NULL},
@@ -454,6 +454,9 @@ int main(int argc, char *argv[])
        // Open the output file.
        if (out_filename) {
                // Output filename specified.
+               // NOTE: out_filename is a pointer to argv,
+               // so duplicate it to prevent issues.
+               out_filename = strdup(out_filename);
                f_wav = fopen(out_filename, "wb");
        } else {
                // Output filename not specified.