From 5431c2cd90093efc88ebaaf3538b42247f83ea56 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 22 Apr 2023 13:45:01 +0000 Subject: [PATCH] Fix double-free in UiaCleanup(). --- src/Uia.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Uia.c b/src/Uia.c index 9d4221e..4ca36a5 100644 --- a/src/Uia.c +++ b/src/Uia.c @@ -493,6 +493,8 @@ UiaCleanup(MatrixHttpHandlerArgs * args) unsigned long lastAccess; + Log(LOG_DEBUG, "Looking at session %s", session); + if (!ref) { Log(LOG_ERR, "Unable to lock uia %s for inspection.", @@ -502,16 +504,15 @@ UiaCleanup(MatrixHttpHandlerArgs * args) lastAccess = JsonValueAsInteger(HashMapGet(DbJson(ref), "last_access")); + DbUnlock(args->db, ref); + /* If last access was greater than 15 minutes ago, remove this * session */ if (UtilServerTs() - lastAccess > 1000 * 60 * 15) { - DbUnlock(args->db, ref); DbDelete(args->db, 2, "user_interactive", session); Log(LOG_DEBUG, "Deleted session %s", session); } - - DbUnlock(args->db, ref); } DbListFree(sessions);