elm_entry: make file loading succeed on 0-sized files

a file which has no data is still a valid file and should be correctly
opened

fix T6562
@fix

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7647
This commit is contained in:
Mike Blumenkrantz 2019-01-16 11:24:36 -05:00 committed by Cedric BAIL
parent f1f3607f8c
commit bb09142477
1 changed files with 11 additions and 5 deletions

View File

@ -143,18 +143,24 @@ _file_load(const char *file)
Eina_File *f;
char *text = NULL;
void *tmp = NULL;
size_t size;
f = eina_file_open(file, EINA_FALSE);
if (!f) return NULL;
tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
if (!tmp) goto on_error;
size = eina_file_size_get(f);
if (size)
{
tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
if (!tmp) goto on_error;
}
text = malloc(eina_file_size_get(f) + 1);
text = malloc(size + 1);
if (!text) goto on_error;
memcpy(text, tmp, eina_file_size_get(f));
text[eina_file_size_get(f)] = 0;
if (size)
memcpy(text, tmp, size);
text[size] = 0;
if (eina_file_map_faulted(f, tmp))
{