Code

Include strings.h instead of defining _BSD_SOURCE to get strcasecmp.
[sysdb.git] / src / core / object.c
index 177ac4c3ada9a76009805187d0a0cd4eda322b9e..dfa06551cb62c1353b59d827ea5333c8e7f30187 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 
 /*
  * private types
@@ -82,7 +83,7 @@ sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap)
 {
        sdb_object_t *obj;
 
-       if (type.size <= sizeof(sdb_object_t))
+       if (type.size < sizeof(sdb_object_t))
                return NULL;
 
        obj = malloc(type.size);
@@ -149,6 +150,9 @@ sdb_object_deref(sdb_object_t *obj)
        if (obj->ref_cnt > 0)
                return;
 
+       /* we'd access free'd memory in case ref_cnt < 0 */
+       assert(! obj->ref_cnt);
+
        if (obj->type.destroy)
                obj->type.destroy(obj);