Mercurial > octave
diff src/mkoctfile.in.cc @ 25495:92a64cb5e475
mkoctfile: Prevent invalid string indexing crash.
* mkoctfile.in.cc (main): Avoid out of bounds string index when
looking for output filename extension.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Jun 2018 13:13:07 -0400 |
parents | f35bd5cddedd |
children | 18f5f91f7348 |
line wrap: on
line diff
--- a/src/mkoctfile.in.cc Mon Jun 25 13:05:22 2018 -0400 +++ b/src/mkoctfile.in.cc Mon Jun 25 13:13:07 2018 -0400 @@ -693,10 +693,14 @@ { if (! outputfile.empty ()) { + // FIXME: should probably do a better job of finding the + // filename extension instead of just looking at the filename + // length. + octfile = outputfile; size_t len = octfile.length (); size_t len_ext = output_ext.length (); - if (octfile.substr (len-len_ext) != output_ext) + if (len <= len_ext || octfile.substr (len-len_ext) != output_ext) octfile += output_ext; } else