diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-14 21:13:32 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-14 21:13:32 +0100 |
commit | 23748ccbcd27047b32e322163349528aea671bb2 (patch) | |
tree | 19ef1626d844f89903faa68574226b65bd9f3a84 /src/common.c | |
parent | m (diff) | |
download | sha3sum-23748ccbcd27047b32e322163349528aea671bb2.tar.gz sha3sum-23748ccbcd27047b32e322163349528aea671bb2.tar.bz2 sha3sum-23748ccbcd27047b32e322163349528aea671bb2.tar.xz |
fix --check
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/common.c b/src/common.c index 051e32f..c6ca7f1 100644 --- a/src/common.c +++ b/src/common.c @@ -333,15 +333,14 @@ static int check_checksums(const char* restrict filename, const libkeccak_spec_t else if (got == 0) break; else ptr += (size_t)got; } - size = ptr; - close(fd), fd = -1; - if (ptr == size) { - if (new = realloc(buf, size += 1), new == NULL) + if (new = realloc(buf, size + 1), new == NULL) goto pfail; buf = new; } + size = ptr; + close(fd), fd = -1; buf[size++] = '\n'; for (ptr = 0, stage = 0; ptr < size; ptr++) @@ -358,7 +357,7 @@ static int check_checksums(const char* restrict filename, const libkeccak_spec_t hash_end = ptr, stage = 3; else { - rc = USER_ERROR("file is malformated"); /* FIXME error at end of file! c is zero! why!? */ + rc = USER_ERROR("file is malformated"); goto fail; } } |