Mercurial > octave
changeset 29191:ae5d758c10e1 stable
Increase size of dynamic variable new_argv by 1 to avoid indexing out of array.
* main.in.cc (main): Increase size of dynamically allocated new_argv by 1
to accommodate potential "--gui" option.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 17 Dec 2020 14:23:19 -0800 |
parents | 7f11d59e3af8 |
children | 547fc7f033da b2d5ee958d7f |
files | src/main.in.cc |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.in.cc Thu Dec 17 14:02:18 2020 -0800 +++ b/src/main.in.cc Thu Dec 17 14:23:19 2020 -0800 @@ -235,7 +235,7 @@ // Declaring new_argv static avoids leak warnings when using GCC's // --address-sanitizer option. - static char **new_argv = new char * [argc + 1]; + static char **new_argv = new char * [argc + 2]; int k = 1; @@ -272,19 +272,19 @@ // the --gui option, while continuing to handle signals in the // terminal. // Do not copy the arg now, since we still not know if the - // gui should really be launched. Just store the index + // gui should really be launched. Just store the index. + start_gui = true; idx_gui = i; - start_gui = true; } else if (! strcmp (argv[i], "--persist")) { // FIXME: How can we reliably detect if this option appears - // after a FILE argument. In this case octave ignores - // the option but the GUI might still be launched if + // after a FILE argument. In this case octave ignores + // the option, but the GUI might still be launched if // --gui is also given. + persist_octave = true; - new_argv[k++] = argv[i]; } else if (! strcmp (argv[i], "--eval") || @@ -335,7 +335,7 @@ // At this point, we definitely know whether the gui has to // be launched or not. // gui_libs and start_gui are just about options, not - // the environment. Exit if they don't make sense. + // the environment. Exit if they don't make sense. if (start_gui) { // GUI should be started