Mercurial > hg > octave-kai
changeset 17676:d41c8f96ed06
avoid memory leaks in base_64_encode and base_64_decode (bug #40228)
* data.cc (Fbase64_encode): Free array allocated by
octave_base64_encode.
* oct-base64.cc (octave_base64_decode): Free array allocated by
base64_decode_alloc.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Oct 2013 22:38:43 -0400 |
parents | 83e6baf0bc3f |
children | fd712a12fe53 |
files | libinterp/corefcn/data.cc liboctave/util/oct-base64.cc |
diffstat | 2 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc +++ b/libinterp/corefcn/data.cc @@ -7343,10 +7343,13 @@ reinterpret_cast<const char*> (in.data ()); \ char* out; \ if (! error_state \ - && octave_base64_encode (inc, inlen, &out)) \ - retval(0) = octave_value (out); \ + && octave_base64_encode (inc, inlen, &out)) \ + { \ + retval(0) = octave_value (out); \ + ::free (out); \ + } \ } - + MAKE_INT_BRANCH(int8) else MAKE_INT_BRANCH(int16) else MAKE_INT_BRANCH(int32) @@ -7370,7 +7373,10 @@ char* out; if (! error_state && octave_base64_encode (inc, inlen, &out)) - retval(0) = octave_value (out); + { + retval(0) = octave_value (out); + ::free (out); + } } else { @@ -7382,7 +7388,10 @@ char* out; if (! error_state && octave_base64_encode (inc, inlen, &out)) - retval(0) = octave_value (out); + { + retval(0) = octave_value (out); + ::free (out); + } } } return retval;