Mercurial > octave
changeset 32540:06a541ee4f05 stable
avoid variable-length array declarations
This issue came up in bug #64977.
* file-ops.cc, oct-string.cc: Use OCTAVE_LOCAL_BUFFER instead of
variable-length array.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Dec 2023 13:21:10 -0500 |
parents | cbdd37c5a223 |
children | 9357c0fdd2c1 |
files | liboctave/system/file-ops.cc liboctave/util/oct-string.cc |
diffstat | 2 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/system/file-ops.cc Tue Dec 05 20:06:21 2023 +0100 +++ b/liboctave/system/file-ops.cc Tue Dec 05 13:21:10 2023 -0500 @@ -749,7 +749,7 @@ templatename += "XXXXXX"; // create and copy template to char array for call to gen_tempname - char tname [templatename.length () + 1]; + OCTAVE_LOCAL_BUFFER (char, tname, templatename.length () + 1); strcpy (tname, templatename.c_str ());
--- a/liboctave/util/oct-string.cc Tue Dec 05 20:06:21 2023 +0100 +++ b/liboctave/util/oct-string.cc Tue Dec 05 13:21:10 2023 -0500 @@ -40,6 +40,7 @@ #include "iconv-wrappers.h" #include "lo-ieee.h" #include "lo-mappers.h" +#include "oct-locbuf.h" #include "uniconv-wrappers.h" #include "unistr-wrappers.h" #include "unwind-prot.h" @@ -891,7 +892,7 @@ { // return number of external characters that produce MAX internal ones std::size_t srclen = end-src; - std::size_t offsets[srclen]; + OCTAVE_LOCAL_BUFFER (std::size_t, offsets, srclen); std::size_t lengthp = max; octave_u8_conv_from_encoding_offsets (m_enc.c_str (), src, srclen, offsets, &lengthp);