From 61a65b37ebde3514735c0648e0b4e2f3d34d7d81 Mon Sep 17 00:00:00 2001 From: Nick Rosbrook Date: Thu, 25 Aug 2022 21:06:21 +0200 Subject: [PATCH] siri/db: add NULL check before calling siridb_tasks_dec --- ...-check-before-calling-siridb_tasks_d.patch | 41 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 42 insertions(+) create mode 100644 debian/patches/0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch diff --git a/debian/patches/0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch b/debian/patches/0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch new file mode 100644 index 00000000..ca0e917c --- /dev/null +++ b/debian/patches/0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch @@ -0,0 +1,41 @@ +Description: siri/db: add NULL check before calling siridb_tasks_dec + 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. +Author: Nick Rosbrook +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 +--- +From 90c261499af260f3450b4a2e00ec828bca81211a Mon Sep 17 00:00:00 2001 +From: Nick Rosbrook +Date: Wed, 24 Aug 2022 14:57:07 -0400 +Subject: [PATCH] siri/db: add NULL check before calling siridb_tasks_dec + +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. +--- + src/siri/db/query.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/siri/db/query.c b/src/siri/db/query.c +index 3f9f7a0a..555628e4 100644 +--- a/src/siri/db/query.c ++++ b/src/siri/db/query.c +@@ -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); +-- +2.34.1 + diff --git a/debian/patches/series b/debian/patches/series index e05f2415..20678d8b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ 0001-link-with-libatomic-for-test.patch +0002-siri-db-add-NULL-check-before-calling-siridb_tasks_d.patch -- 2.30.2