Mercurial > octave
changeset 24379:56d1e4d9975e
avoid memory leak in utf8 conversion functions
* strfns.cc (F__native2unicode__, F__native2unicode__):
Set unwind-protect frame after pointer is defined.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Dec 2017 10:12:35 -0500 |
parents | 64a85a19f6e3 |
children | 51a1d6c84d0c |
files | libinterp/corefcn/strfns.cc |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/strfns.cc Thu Dec 07 08:26:19 2017 -0500 +++ b/libinterp/corefcn/strfns.cc Thu Dec 07 10:12:35 2017 -0500 @@ -764,14 +764,14 @@ octave::unwind_protect frame; - frame.add_fcn (::free, static_cast<void *> (utf8_str)); - utf8_str = octave_u8_conv_from_encoding (codepage, src, srclen, &length); if (! utf8_str) error ("native2unicode: converting from codepage '%s' to UTF-8: %s", codepage, std::strerror (errno)); + frame.add_fcn (::free, static_cast<void *> (utf8_str)); + octave_idx_type len = length; charNDArray retval (dim_vector (1, len)); @@ -810,14 +810,14 @@ octave::unwind_protect frame; - frame.add_fcn (::free, static_cast<void *> (native_bytes)); - native_bytes = octave_u8_conv_to_encoding (codepage, src, srclen, &length); if (! native_bytes) error ("native2unicode: converting from UTF-8 to codepage '%s': %s", codepage, std::strerror (errno)); + frame.add_fcn (::free, static_cast<void *> (native_bytes)); + octave_idx_type len = length; uint8NDArray retval (dim_vector (1, len));