forked from enlightenment/efl
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:
parent
f1f3607f8c
commit
bb09142477
|
@ -143,18 +143,24 @@ _file_load(const char *file)
|
||||||
Eina_File *f;
|
Eina_File *f;
|
||||||
char *text = NULL;
|
char *text = NULL;
|
||||||
void *tmp = NULL;
|
void *tmp = NULL;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
f = eina_file_open(file, EINA_FALSE);
|
f = eina_file_open(file, EINA_FALSE);
|
||||||
if (!f) return NULL;
|
if (!f) return NULL;
|
||||||
|
|
||||||
|
size = eina_file_size_get(f);
|
||||||
|
if (size)
|
||||||
|
{
|
||||||
tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
||||||
if (!tmp) goto on_error;
|
if (!tmp) goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
text = malloc(eina_file_size_get(f) + 1);
|
text = malloc(size + 1);
|
||||||
if (!text) goto on_error;
|
if (!text) goto on_error;
|
||||||
|
|
||||||
memcpy(text, tmp, eina_file_size_get(f));
|
if (size)
|
||||||
text[eina_file_size_get(f)] = 0;
|
memcpy(text, tmp, size);
|
||||||
|
text[size] = 0;
|
||||||
|
|
||||||
if (eina_file_map_faulted(f, tmp))
|
if (eina_file_map_faulted(f, tmp))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue