eldbus_service: Prevent memory leak

Summary:
If obj->introspection_data is null, the function returns
without freeing the memory.

Test Plan: N/A

Reviewers: Hermet, YOhoho

Reviewed By: YOhoho

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11345
This commit is contained in:
junsu choi 2020-02-14 16:27:12 +09:00
parent 2ba77c0a33
commit 65dae7876d
1 changed files with 4 additions and 1 deletions

View File

@ -365,7 +365,7 @@ cb_introspect(const Eldbus_Service_Interface *_iface, const Eldbus_Message *mess
eina_strbuf_reset(obj->introspection_data);
else
obj->introspection_data = eina_strbuf_new();
EINA_SAFETY_ON_NULL_RETURN_VAL(obj->introspection_data, NULL);
EINA_SAFETY_ON_NULL_GOTO(obj->introspection_data, fail);
eina_strbuf_append(obj->introspection_data, "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">");
eina_strbuf_append_printf(obj->introspection_data,
@ -392,6 +392,9 @@ cb_introspect(const Eldbus_Service_Interface *_iface, const Eldbus_Message *mess
eldbus_message_arguments_append(reply, "s", eina_strbuf_string_get(obj->introspection_data));
return reply;
fail:
if (reply) eldbus_message_unref(reply);
return NULL;
}
static const Eldbus_Method introspect = {