fix: free parser on error
Found while looking into #105 but the opposite problem. This frees the parser after an error has occurred and early return.
This commit is contained in:
@@ -35,6 +35,8 @@ size_t ContainerParser::write(const uint8_t* buffer, const size_t size) {
|
||||
void* const buf = XML_GetBuffer(parser, 1024);
|
||||
if (!buf) {
|
||||
LOG_DBG("CTR", "Couldn't allocate buffer");
|
||||
XML_ParserFree(parser);
|
||||
parser = nullptr;
|
||||
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) {
|
||||
LOG_ERR("CTR", "Parse error: %s", XML_ErrorString(XML_GetErrorCode(parser)));
|
||||
XML_ParserFree(parser);
|
||||
parser = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user