From 9b4a5ef2a407895415153f78b69a954ed414715b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 1 Dec 2013 16:55:13 +0100 Subject: [PATCH] object: Ensure that a type's destroy callback is called if init fails. Else, failed init may leak memory. --- src/core/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- 2.30.2