]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
prioq: check if identical compare func is specified if already allocated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 May 2025 17:01:55 +0000 (02:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 May 2025 20:58:33 +0000 (05:58 +0900)
src/basic/prioq.c

index 0ff5faaff331ce9d6d47784ec34f5fe9c957d6bf..97e3fd936faf55846e7a84aa269633c7663ac1fe 100644 (file)
@@ -58,8 +58,10 @@ Prioq* prioq_free(Prioq *q) {
 int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
         assert(q);
 
-        if (*q)
+        if (*q) {
+                assert((*q)->compare_func == compare_func);
                 return 0;
+        }
 
         *q = prioq_new(compare_func);
         if (!*q)