summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2017-07-20 11:13:09 +0200
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>2017-08-01 14:49:50 +0000
commit76f4dbcf55a786b1e826f6d79fd4317d2369d35f (patch)
tree1da9a8468377fc06dfc407a85d37d803bff053ea
parentae845ad8061da45df7e0aea74f3b225bceceac4d (diff)
downloadkey-manager-76f4dbcf55a786b1e826f6d79fd4317d2369d35f.tar.gz
key-manager-76f4dbcf55a786b1e826f6d79fd4317d2369d35f.tar.bz2
key-manager-76f4dbcf55a786b1e826f6d79fd4317d2369d35f.zip
Fix segfault in internal tests
Unregister libxml2 callbacks in parser destructor. Change-Id: Ieeeaebc9299df55325612800304c32f55708091c
-rw-r--r--src/manager/initial-values/parser.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/manager/initial-values/parser.cpp b/src/manager/initial-values/parser.cpp
index 6b393d4b..4bb0b6ab 100644
--- a/src/manager/initial-values/parser.cpp
+++ b/src/manager/initial-values/parser.cpp
@@ -58,6 +58,8 @@ Parser::Parser(const std::string &XML_filename) :
}
Parser::~Parser()
{
+ xmlSetGenericErrorFunc(NULL, NULL);
+ xmlThrDefSetGenericErrorFunc(NULL, NULL);
}
using SchemaParserCtxt =
@@ -83,6 +85,9 @@ int Parser::Validate(const std::string &XSD_schema)
return ERROR_INVALID_ARGUMENT;
}
+ xmlSetGenericErrorFunc(this, &Parser::ErrorValidate);
+ xmlThrDefSetGenericErrorFunc(this, &Parser::ErrorValidate);
+
Schema schema(xmlSchemaParse(parserCtxt.get()), [](xmlSchemaPtr schemaPtr) {
xmlSchemaFree(schemaPtr);
});
@@ -102,11 +107,6 @@ int Parser::Validate(const std::string &XSD_schema)
return ERROR_INTERNAL;
}
- xmlSetStructuredErrorFunc(NULL, NULL);
- xmlSetGenericErrorFunc(this, &Parser::ErrorValidate);
- xmlThrDefSetStructuredErrorFunc(NULL, NULL);
- xmlThrDefSetGenericErrorFunc(this, &Parser::ErrorValidate);
-
retCode = xmlSchemaValidateFile(validCtxt.get(), m_XMLfile.c_str(), 0);
if (0 != retCode) {
@@ -126,6 +126,9 @@ int Parser::Parse()
return ERROR_INVALID_ARGUMENT;
}
+ xmlSetGenericErrorFunc(this, &Parser::Error);
+ xmlThrDefSetGenericErrorFunc(this, &Parser::Error);
+
int retCode = xmlSAXUserParseFile(&m_saxHandler, this, m_XMLfile.c_str());
if (0 != retCode) {