Mercurial > octave
changeset 29978:c7c69808356f
jsondecode.cc: Avoid dereferencing invalid pointer.
* libinterp/corefcn/jsondecode.cc (Fjsondecode): Avoid invalid pointer
dereferencing with make_valid_name_options object in limited scope.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 17 Aug 2021 09:55:02 +0200 |
parents | 0d67814eb038 |
children | ac5e1b64f8c9 |
files | libinterp/corefcn/jsondecode.cc |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/jsondecode.cc Tue Aug 17 14:54:29 2021 +0900 +++ b/libinterp/corefcn/jsondecode.cc Tue Aug 17 09:55:02 2021 +0200 @@ -555,13 +555,11 @@ make_valid_name_params.append (args.slice(i, 2)); } - make_valid_name_options* options = nullptr; + make_valid_name_options *options + = use_makeValidName ? new make_valid_name_options (make_valid_name_params) + : nullptr; - if (use_makeValidName) - { - make_valid_name_options options_obj (make_valid_name_params); - options = &options_obj; - } + unwind_action del_opts ([options] (void) { if (options) delete options; }); if (! args(0).is_string ()) error ("jsondecode: JSON_TXT must be a character string");