diff options
author | Vicent Marti <tanoku@gmail.com> | 2012-09-12 01:05:24 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2012-09-12 01:05:24 +0400 |
commit | c859184bb459d9801a394dc44f5b0b0e55453263 (patch) | |
tree | 33039b8911dbcba39e9270b73ee152956444f43d /src/amiga | |
parent | 1f35e89dbf6e0be8952cc4324a45fd600be5ca05 (diff) |
Properly handle p_reads
Diffstat (limited to 'src/amiga')
-rwxr-xr-x | src/amiga/map.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/amiga/map.c b/src/amiga/map.c index 2fb065c8b..c601de724 100755 --- a/src/amiga/map.c +++ b/src/amiga/map.c @@ -24,18 +24,15 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs return -1; } - if((out->data = malloc(len))) { - p_lseek(fd, offset, SEEK_SET); - p_read(fd, out->data, len); - } + out->data = malloc(len); + GITERR_CHECK_ALLOC(out->data); - if (!out->data || (out->data == MAP_FAILED)) { - giterr_set(GITERR_OS, "Failed to mmap. Could not write data"); + if (p_lseek(fd, offset, SEEK_SET) < 0 || p_read(fd, out->data, len) != len) + giterr_set(GITERR_OS, "mmap emulation failed"); return -1; } out->len = len; - return 0; } |