diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.cc index 13bf3ccf233..3d8ea8208e0 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.cc @@ -2380,13 +2380,14 @@ int4 xml_parse(istream &i,ContentHandler *hand,int4 dbg) #if YYDEBUG yydebug = dbg; #endif - global_scan = new XmlScan(i); + auto scan = make_unique(i); + global_scan = scan.get(); // raw observer pointer for yyparse / yylex / grammar actions handler = hand; handler->startDocument(); int4 res = yyparse(); if (res == 0) handler->endDocument(); - delete global_scan; + global_scan = (XmlScan *)0; // scan goes out of scope below — null the observer first return res; } diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.y b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.y index f50093b8c31..28896aa347a 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml.y +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml.y @@ -522,13 +522,14 @@ int4 xml_parse(istream &i,ContentHandler *hand,int4 dbg) #if YYDEBUG yydebug = dbg; #endif - global_scan = new XmlScan(i); + auto scan = make_unique(i); + global_scan = scan.get(); // raw observer pointer for yyparse / yylex / grammar actions handler = hand; handler->startDocument(); int4 res = yyparse(); if (res == 0) handler->endDocument(); - delete global_scan; + global_scan = (XmlScan *)0; // scan goes out of scope below — null the observer first return res; }