diff options
author | Stefan Schmidt <stefan@osg.samsung.com> | 2017-07-20 16:15:32 +0200 |
---|---|---|
committer | Stefan Schmidt <stefan@osg.samsung.com> | 2017-07-20 16:15:32 +0200 |
commit | cc924aacde7b14b967fe579023e1475810e66c83 (patch) | |
tree | 6d6e4285370e94c920ab32565045d5fb6721c106 | |
parent | 152f4b4b4fb7256dc849f95ea0107dea5f9891d1 (diff) | |
download | efl-cc924aacde7b14b967fe579023e1475810e66c83.tar.gz |
eldbus: codegen: free allocated strbuf in error path
fname would have been leaked if we failed to get a file_handler.
Also make sure we always create a new fname strbuf even without
a output_dir present to fix a potential unbalance between creating
and freeing.
CID: 1378112
-rw-r--r-- | src/bin/eldbus/utils.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/eldbus/utils.c b/src/bin/eldbus/utils.c index aaad290609..ae1f4935f9 100644 --- a/src/bin/eldbus/utils.c +++ b/src/bin/eldbus/utils.c @@ -37,9 +37,10 @@ file_write(const char *file_name, const char *buffer) const char *filename = file_name; Eina_Strbuf *fname = NULL; + fname = eina_strbuf_new(); + if (output_dir) { - fname = eina_strbuf_new(); eina_strbuf_append_printf(fname, "%s/%s", output_dir, file_name); filename = eina_strbuf_string_get(fname); } @@ -47,6 +48,7 @@ file_write(const char *file_name, const char *buffer) if (!file_handler) { printf("Error to write file: %s\n", file_name); + eina_strbuf_free(fname); return EINA_FALSE; } |