[xml] [PATCH] Fix xsltExtModuleFunctionLookup() / xsltExtModuleRegisterDynamic() deadlock.



Fix a deadlock when encountering extensions that do not exist on the supported platform at
all. Both xsltExtModuleFunctionLookup() and xsltExtModuleRegisterDynamic() take the
xsltExtMutex, but the former calls the latter -> deadlock.

Dropping the mutex and taking it again is safe, as xsltExtModuleRegisterDynamic() checks that
it has not already been called for a particular module. So do that.

---
 libxslt/extensions.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index 3b99de8..a797c39 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -1424,6 +1424,8 @@ xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
 
     XML_CAST_FPTR(ret) = xmlHashLookup2(xsltFunctionsHash, name, URI);
 
+    xmlMutexUnlock(xsltExtMutex);
+
     /* if lookup fails, attempt a dynamic load on supported platforms */
     if (NULL == ret) {
         if (!xsltExtModuleRegisterDynamic(URI)) {
@@ -1432,8 +1434,6 @@ xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
         }
     }
 
-    xmlMutexUnlock(xsltExtMutex);
-
     return ret;
 }
 
-- 
1.6.4.2.96.g35d79



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]