Code

frontend: Fix a memory leak in an error condition in FETCH.
authorSebastian Harl <sh@tokkee.org>
Wed, 25 Feb 2015 09:39:34 +0000 (10:39 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 25 Feb 2015 09:39:34 +0000 (10:39 +0100)
src/frontend/query.c

index cc107c6ed46f7f1eb38a1ae3efea3ea94d8d4e2a..2bd234a07c91088ac8f8db4706acd1c42f2896e1 100644 (file)
@@ -331,10 +331,14 @@ sdb_fe_exec_fetch(sdb_conn_t *conn, int type,
                        sdb_strbuf_sprintf(conn->errbuf, "Failed to fetch %s %s.%s: "
                                        "%s not found", SDB_STORE_TYPE_TO_NAME(type),
                                        hostname, name, name);
+                       if (obj)
+                               sdb_object_deref(SDB_OBJ(obj));
+                       sdb_object_deref(SDB_OBJ(host));
                        return -1;
                }
                sdb_object_deref(SDB_OBJ(host));
        }
+       host = NULL;
 
        buf = sdb_strbuf_create(1024);
        if (! buf) {