From: Sebastian Harl Date: Sun, 1 Dec 2013 15:55:13 +0000 (+0100) Subject: object: Ensure that a type's destroy callback is called if init fails. X-Git-Tag: sysdb-0.1.0~340 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=9b4a5ef2a407895415153f78b69a954ed414715b object: Ensure that a type's destroy callback is called if init fails. Else, failed init may leak memory. --- diff --git a/src/core/object.c b/src/core/object.c index 0205ed5..43bb22a 100644 --- a/src/core/object.c +++ b/src/core/object.c @@ -85,6 +85,7 @@ sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap) if (! obj) return NULL; memset(obj, 0, type.size); + obj->type = type; if (name) { obj->name = strdup(name); @@ -103,7 +104,6 @@ sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap) } } - obj->type = type; obj->ref_cnt = 1; return obj; } /* sdb_object_vcreate */