From: H. Peter Anvin Date: Mon, 16 Jun 2008 00:03:18 +0000 (-0700) Subject: loadfile: make sure we don't trash errno X-Git-Tag: syslinux-3.70-pre18~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99d175aa34800b281c65210ce436cf0a423906fc;p=profile%2Fivi%2Fsyslinux.git loadfile: make sure we don't trash errno Make sure we don't trash a useful value in errno. --- diff --git a/com32/lib/syslinux/loadfile.c b/com32/lib/syslinux/loadfile.c index 42a1fd6..7ad8e81 100644 --- a/com32/lib/syslinux/loadfile.c +++ b/com32/lib/syslinux/loadfile.c @@ -31,6 +31,7 @@ * Read the contents of a data file into a malloc'd buffer */ +#include #include #include #include @@ -45,14 +46,18 @@ int loadfile(const char *filename, void **ptr, size_t *len) { FILE *f; - int rv; + int rv, e; f = fopen(filename, "r"); if ( !f ) return -1; rv = floadfile(f, ptr, len, NULL, 0); + e = errno; + fclose(f); + if (rv) + errno = e; return rv; }