summaryrefslogtreecommitdiff
path: root/src/bin/eldbus
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@osg.samsung.com>2017-07-20 16:15:32 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2017-07-20 16:15:32 +0200
commitcc924aacde7b14b967fe579023e1475810e66c83 (patch)
tree6d6e4285370e94c920ab32565045d5fb6721c106 /src/bin/eldbus
parent152f4b4b4fb7256dc849f95ea0107dea5f9891d1 (diff)
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
Diffstat (limited to 'src/bin/eldbus')
-rw-r--r--src/bin/eldbus/utils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/eldbus/utils.c b/src/bin/eldbus/utils.c
index aaad290..ae1f493 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)
37 const char *filename = file_name; 37 const char *filename = file_name;
38 Eina_Strbuf *fname = NULL; 38 Eina_Strbuf *fname = NULL;
39 39
40 fname = eina_strbuf_new();
41
40 if (output_dir) 42 if (output_dir)
41 { 43 {
42 fname = eina_strbuf_new();
43 eina_strbuf_append_printf(fname, "%s/%s", output_dir, file_name); 44 eina_strbuf_append_printf(fname, "%s/%s", output_dir, file_name);
44 filename = eina_strbuf_string_get(fname); 45 filename = eina_strbuf_string_get(fname);
45 } 46 }
@@ -47,6 +48,7 @@ file_write(const char *file_name, const char *buffer)
47 if (!file_handler) 48 if (!file_handler)
48 { 49 {
49 printf("Error to write file: %s\n", file_name); 50 printf("Error to write file: %s\n", file_name);
51 eina_strbuf_free(fname);
50 return EINA_FALSE; 52 return EINA_FALSE;
51 } 53 }
52 54