aboutsummaryrefslogtreecommitdiff
path: root/libelftc/elftc_copyfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelftc/elftc_copyfile.c')
-rw-r--r--libelftc/elftc_copyfile.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libelftc/elftc_copyfile.c b/libelftc/elftc_copyfile.c
index 0bacaf45e769a..7df1678e702dc 100644
--- a/libelftc/elftc_copyfile.c
+++ b/libelftc/elftc_copyfile.c
@@ -37,7 +37,7 @@
#include <sys/mman.h>
#endif
-ELFTC_VCSID("$Id: elftc_copyfile.c 2318 2011-12-11 10:54:27Z jkoshy $");
+ELFTC_VCSID("$Id: elftc_copyfile.c 2981 2014-02-01 02:41:13Z jkoshy $");
/*
* Copy the contents referenced by 'ifd' to 'ofd'. Returns 0 on
@@ -79,11 +79,13 @@ elftc_copyfile(int ifd, int ofd)
* If mmap() is not available, or if the mmap() operation
* failed, allocate a buffer, and read in input data.
*/
- if (buf == NULL) {
+ if (buf_mmapped == false) {
if ((buf = malloc(sb.st_size)) == NULL)
return (-1);
- if (read(ifd, buf, sb.st_size) != sb.st_size)
+ if (read(ifd, buf, sb.st_size) != sb.st_size) {
+ free(buf);
return (-1);
+ }
}
/*