evas 3d - fix error handling for ftell from coverity

coverity was right again - CID 1222453 - fix.
This commit is contained in:
Carsten Haitzler 2014-08-13 20:57:33 +09:00
parent dad62cc323
commit 72f1a2600b
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,11 @@ _file_to_buf(const char *file, long *length)//prepare text file for reading
if (!file_for_print) return NULL;
fseek(file_for_print, 0, SEEK_END);//set file_for_print to the end of file
*length = ftell(file_for_print);//set current position of file_for_print
if (*length < 0)
{
fclose(file_for_print);
return NULL;
}
buf = malloc(*length + 1);
fseek(file_for_print, 0, SEEK_SET);//set file_for_print to the begining of file
unused = fread(buf, *length, 1, file_for_print);