diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 650e959907..fd2500eba6 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -708,9 +708,9 @@ data_write_groups(Eet_File *ef, int *collection_num) } static void -create_script_file(Eet_File *ef, const char *filename, const Code *cd) +create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) { - FILE *f = fopen(filename, "wb"); + FILE *f = fdopen(fd, "wb"); if (!f) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", filename); @@ -787,7 +787,7 @@ create_script_file(Eet_File *ef, const char *filename, const Code *cd) static void compile_script_file(Eet_File *ef, const char *source, const char *output, - int script_num) + int script_num, int fd) { FILE *f; char buf[4096]; @@ -802,7 +802,7 @@ compile_script_file(Eet_File *ef, const char *source, const char *output, if (ret < 0 || ret > 1) error_and_abort(ef, "Compiling script code not clean.\n"); - f = fopen(output, "rb"); + f = fdopen(fd, "rb"); if (!f) error_and_abort(ef, "Unable to open script object \"%s\" for reading.\n", output); @@ -864,8 +864,7 @@ data_write_scripts(Eet_File *ef) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", tmpn); - create_script_file(ef, tmpn, cd); - close(fd); + create_script_file(ef, tmpn, cd, fd); snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); fd = mkstemp(tmpo); @@ -875,9 +874,7 @@ data_write_scripts(Eet_File *ef) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", tmpn); } - - compile_script_file(ef, tmpn, tmpo, i); - close(fd); + compile_script_file(ef, tmpn, tmpo, i, fd); unlink(tmpn); unlink(tmpo);