eldbus: create object when needed
authorSebastian Dransfeld <sd@tango.flipp.net>
Sat, 7 Dec 2013 13:07:29 +0000 (14:07 +0100)
committerSebastian Dransfeld <sd@tango.flipp.net>
Sat, 7 Dec 2013 20:11:32 +0000 (21:11 +0100)
We allocate the strbuf at the beginning of the function, but do several
return checks after this which does not free the strbuf before return,
and we don't use the strbuf.

So create the strbuf object after checks, just before we need it.

Fixes CID 1039287

src/bin/eldbus/parser.c

index 73e4f41..a74ff07 100644 (file)
@@ -199,7 +199,7 @@ open_signal(const char *content, unsigned length, Eina_Bool is_open_empty)
    Eina_Bool r;
    char *tmp;
    int i;
-   Eina_Strbuf *buf = eina_strbuf_new();
+   Eina_Strbuf *buf;
 
    d_signal = signal_new(iface);
    EINA_SAFETY_ON_NULL_RETURN_VAL(d_signal, EINA_FALSE);
@@ -213,6 +213,7 @@ open_signal(const char *content, unsigned length, Eina_Bool is_open_empty)
         return EINA_FALSE;
      }
 
+   buf = eina_strbuf_new();
    tmp = dbus_name_to_c(d_signal->name);
    d_signal->c_name = string_build("%s_%s", iface->c_name, tmp);
    free(tmp);