edje_cc - fix potential divide by 0 in info output if file size is 0

this will realistically never happen in a sane case... but its
theoretically possible. fixes CID 1366923
This commit is contained in:
Carsten Haitzler 2017-02-08 16:43:50 +09:00
parent f6638432d3
commit 5b4c032fb5
1 changed files with 3 additions and 1 deletions

View File

@ -786,6 +786,7 @@ data_thread_fonts(void *data, Ecore_Thread *thread EINA_UNUSED)
int bytes = 0;
char buf[EINA_PATH_MAX];
char buf2[EINA_PATH_MAX];
size_t size;
f = eina_file_open(fc->fn->file, 0);
if (f)
@ -835,9 +836,10 @@ data_thread_fonts(void *data, Ecore_Thread *thread EINA_UNUSED)
return;
}
size = eina_file_size_get(f);
INF("Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]",
bytes, (bytes + 512) / 1024, buf, fc->fn->file,
100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f)))
100 - (100 * (double)bytes) / ((double)((size > 0) ? size : 1))
);
eina_file_map_free(f, m);
eina_file_close(f);