]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: make sure more bitmap calls can deal with NULL objects fine
authorLennart Poettering <lennart@poettering.net>
Mon, 21 Dec 2015 18:53:15 +0000 (19:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 26 Dec 2015 18:09:10 +0000 (19:09 +0100)
src/basic/bitmap.c

index 95f59e400a4e13bae9ea9bb86729324106269725..c8b2427b1cf35552f843370fc3e3d521133ad111 100644 (file)
@@ -140,7 +140,8 @@ bool bitmap_isset(Bitmap *b, unsigned n) {
 bool bitmap_isclear(Bitmap *b) {
         unsigned i;
 
-        assert(b);
+        if (!b)
+                return true;
 
         for (i = 0; i < b->n_bitmaps; i++)
                 if (b->bitmaps[i] != 0)
@@ -150,7 +151,9 @@ bool bitmap_isclear(Bitmap *b) {
 }
 
 void bitmap_clear(Bitmap *b) {
-        assert(b);
+
+        if (!b)
+                return;
 
         b->bitmaps = mfree(b->bitmaps);
         b->n_bitmaps = 0;