Index: libX11-1.4.99.1/src/Xrm.c
===================================================================
--- libX11-1.4.99.1.orig/src/Xrm.c
+++ libX11-1.4.99.1/src/Xrm.c
@@ -2540,30 +2540,40 @@ Bool XrmQGetResource(
     VClosureRec closure;
 
     if (db && *names) {
-	_XLockMutex(&db->linfo);
+	if ((_XLockMutex_fn) && db->linfo.lock ) {
+	    _XLockMutex(&db->linfo);
+	}
 	closure.type = pType;
 	closure.value = pValue;
 	table = db->table;
 	if (names[1]) {
 	    if (table && !table->leaf) {
 		if (GetNEntry(table, names, classes, &closure)) {
-		    _XUnlockMutex(&db->linfo);
+		    if ((_XUnlockMutex_fn) && db->linfo.lock ) {
+		        _XUnlockMutex(&db->linfo);
+		    }
 		    return True;
 		}
 	    } else if (table && table->hasloose &&
 		    GetLooseVEntry((LTable)table, names, classes, &closure)) {
-		_XUnlockMutex (&db->linfo);
+		if ((_XUnlockMutex_fn) && db->linfo.lock ) {
+		    _XUnlockMutex (&db->linfo);
+		}
 		return True;
 	    }
 	} else {
 	    if (table && !table->leaf)
 		table = table->next;
 	    if (table && GetVEntry((LTable)table, names, classes, &closure)) {
-		_XUnlockMutex(&db->linfo);
+		if ((_XUnlockMutex_fn) && db->linfo.lock ) {
+		    _XUnlockMutex(&db->linfo);
+		}
 		return True;
 	    }
 	}
-	_XUnlockMutex(&db->linfo);
+	if ((_XUnlockMutex_fn) && db->linfo.lock ) {
+	    _XUnlockMutex(&db->linfo);
+	}
     }
     *pType = NULLQUARK;
     pValue->addr = (XPointer)NULL;
