summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wagner <bungeman@chromium.org>2021-08-31 12:47:48 -0400
committerAkira TAGOH <akira@tagoh.org>2021-09-06 03:20:31 +0000
commitefc71a3c132be05461ffc872e70390d61f27bc7e (patch)
treef9d1e5cd37c974979ff8ea2247ed3ad1bbda2be0
parent6e68763085b2a9003b3b5fab4ff6418a667124f2 (diff)
downloadfontconfig-efc71a3c132be05461ffc872e70390d61f27bc7e.tar.gz
Free local FcCache lock on contention
If two threads attempt to create the FcCache lock in lock_cache at the same time, both threads may create and initialize a local FcMutex. One thread will atomically make cache_lock point to its FcMutex. The other thread currently calls FcMutexFinish on the local lock, but does not free it. Change this behavior to free the unused lock. Found with test/test-pthread on an LeakSanitizer enabled build.
-rw-r--r--src/fccache.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/fccache.c b/src/fccache.c
index d8ffe09..4a6a752 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -495,6 +495,7 @@ retry:
FcMutexInit (lock);
if (!fc_atomic_ptr_cmpexch (&cache_lock, NULL, lock)) {
FcMutexFinish (lock);
+ free (lock);
goto retry;
}