# HG changeset patch # User Markus Mützel # Date 1629186902 -7200 # Node ID c7c69808356f8e16b7d80b82350c60ee9b5fab08 # Parent 0d67814eb0387116c268d7df348165cbf203dfbc jsondecode.cc: Avoid dereferencing invalid pointer. * libinterp/corefcn/jsondecode.cc (Fjsondecode): Avoid invalid pointer dereferencing with make_valid_name_options object in limited scope. diff -r 0d67814eb038 -r c7c69808356f libinterp/corefcn/jsondecode.cc --- 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");