Hash :
763e2b7e
Author :
Date :
2016-03-13T20:24:44
src/utils: check if fileno() failed in map_file
fileno() can fail, if called on e.g. fmemopen() FILEs which are not
backed by a file descriptor. This functions uses mmap to map the entire
file to memory, so using such FILEs will not work.
(There is actually no change of behavior here, since the following fstat
would have already failed with EBADF. But lets make it clear.)
Another possibility is to fall back to the !HAVE_MMAP case; but it
sounds like a better idea to leave it to the programmer to use the
new_from_string/new_from_buffer functions instead, instead of doing
double allocation behind their back.
Signed-off-by: Ran Benita <ran234@gmail.com>