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
This commit is contained in:
Stefan Schmidt 2017-07-20 16:15:32 +02:00
parent 152f4b4b4f
commit cc924aacde
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}