siri/db: add NULL check before calling siridb_tasks_dec
authorNick Rosbrook <nick.rosbrook@canonical.com>
Thu, 25 Aug 2022 19:06:59 +0000 (21:06 +0200)
committerPaul Gevers <elbrus@debian.org>
Thu, 25 Aug 2022 19:06:59 +0000 (21:06 +0200)
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/siridb-server/+bug/1987558
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1017748
Forwarded: https://github.com/SiriDB/siridb-server/pull/182
Last-Update: 2022-08-24

When built against libuv1 1.44.2, siridb_query_free may call
siridb_tasks_dec on NULL, causing a segfault. Add a NULL check on siridb
before calling siridb_tasks_dec to avoid this.
Last-Update: 2022-08-24
Gbp-Pq: Name 0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch

src/siri/db/query.c

index 3f9f7a0ae2cbc34d8d592524d533c1d945998985..555628e44fdf440fe9c78bc9ad81fcdf650d70dc 100644 (file)
@@ -156,7 +156,10 @@ void siridb_query_free(uv_handle_t * handle)
     siridb_t * siridb = query->client->siridb;
 
     /* decrement active tasks */
-    siridb_tasks_dec(siridb->tasks);
+    if (siridb != NULL)
+    {
+        siridb_tasks_dec(siridb->tasks);
+    }
 
     /* free query */
     free(query->q);