Skip to content

Commit 2e412be

Browse files
committed
Fix memory corruption (lcf2xml) and memory leak (XmlReader)
1 parent 3dd0a31 commit 2e412be

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/reader_xml.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ XmlReader::~XmlReader() {
5353
if (parser != NULL)
5454
XML_ParserFree(parser);
5555
parser = NULL;
56+
57+
if (!handlers.empty()) {
58+
delete(handlers.back());
59+
}
5660
#endif
5761
}
5862

tools/lcf2xml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ FileTypes GetFiletype(const std::string& in_file, std::string& out_extension)
208208
return FileType_LCF_MapUnit;
209209
} else if (input == "?xml versi") {
210210
in.read(buf, 128);
211-
std::string in(buf);
211+
std::string in(std::begin(buf), std::end(buf));
212212

213213
size_t pos = in.find('<');
214214
if (pos != std::string::npos)

0 commit comments

Comments
 (0)