Merge pull request #107 from jgoguen/fix-parser-not-freed

fix: free parser on error
This commit is contained in:
jpirnay
2026-04-20 14:07:23 +02:00
committed by GitHub
@@ -35,6 +35,8 @@ size_t ContainerParser::write(const uint8_t* buffer, const size_t size) {
void* const buf = XML_GetBuffer(parser, 1024); void* const buf = XML_GetBuffer(parser, 1024);
if (!buf) { if (!buf) {
LOG_DBG("CTR", "Couldn't allocate buffer"); LOG_DBG("CTR", "Couldn't allocate buffer");
XML_ParserFree(parser);
parser = nullptr;
return 0; return 0;
} }
@@ -43,6 +45,8 @@ size_t ContainerParser::write(const uint8_t* buffer, const size_t size) {
if (XML_ParseBuffer(parser, static_cast<int>(toRead), remainingSize == toRead) == XML_STATUS_ERROR) { if (XML_ParseBuffer(parser, static_cast<int>(toRead), remainingSize == toRead) == XML_STATUS_ERROR) {
LOG_ERR("CTR", "Parse error: %s", XML_ErrorString(XML_GetErrorCode(parser))); LOG_ERR("CTR", "Parse error: %s", XML_ErrorString(XML_GetErrorCode(parser)));
XML_ParserFree(parser);
parser = nullptr;
return 0; return 0;
} }