From 94f0fef0a4ec78f16dcb1270deccc86f0274ef95 Mon Sep 17 00:00:00 2001 From: "oleg.hoefling" Date: Sat, 29 May 2021 00:13:38 +0200 Subject: [PATCH] reinstall custom error callback after xmlSecCryptoInit() Signed-off-by: oleg.hoefling --- src/main.c | 10 +++++----- tests/test_xmlsec.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index c93b16d2..eef975a9 100644 --- a/src/main.c +++ b/src/main.c @@ -87,6 +87,11 @@ static int PyXmlSec_Init(void) { PyXmlSec_Free(_PYXMLSEC_FREE_ALL); return -1; } + // xmlsec will install default callback in xmlSecCryptoInit, + // overwriting any custom callbacks. + // We thus reinstall our callback now. + PyXmlSec_InstallErrorCallback(); + free_mode = _PYXMLSEC_FREE_ALL; return 0; } @@ -239,11 +244,6 @@ PYENTRY_FUNC_NAME(void) if (PyXmlSec_Init() < 0) goto ON_FAIL; - // xmlsec will install default callback in PyXmlSec_Init, - // overwriting any custom callbacks. - // We thus install our callback again now. - PyXmlSec_InstallErrorCallback(); - if (PyModule_AddStringConstant(module, "__version__", STRINGIFY(MODULE_VERSION)) < 0) goto ON_FAIL; if (PyXmlSec_InitLxmlModule() < 0) goto ON_FAIL; diff --git a/tests/test_xmlsec.py b/tests/test_xmlsec.py index 2d470a11..32fac69a 100644 --- a/tests/test_xmlsec.py +++ b/tests/test_xmlsec.py @@ -10,5 +10,5 @@ def test_reinitialize_module(self): tests don't fail, we know that the ``init()``/``shutdown()`` function pair doesn't break anything. """ - # xmlsec.shutdown() - # xmlsec.init() + xmlsec.shutdown() + xmlsec.init()