mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Cast the mallocs to their variable type.
Check that read and write actually return greater than zero.
This commit is contained in:
parent
3879807865
commit
f2d33c00f8
4
runzip.c
4
runzip.c
|
|
@ -71,7 +71,7 @@ static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum)
|
||||||
if (unlikely(len < 0))
|
if (unlikely(len < 0))
|
||||||
fatal("len %lld is negative in unzip_literal!\n",len);
|
fatal("len %lld is negative in unzip_literal!\n",len);
|
||||||
|
|
||||||
buf = malloc(len);
|
buf = (uchar *)malloc(len);
|
||||||
if (unlikely(!buf))
|
if (unlikely(!buf))
|
||||||
fatal("Failed to malloc literal buffer of size %lld\n", len);
|
fatal("Failed to malloc literal buffer of size %lld\n", len);
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
n = MIN(len, offset);
|
n = MIN(len, offset);
|
||||||
|
|
||||||
buf = malloc(n);
|
buf = (uchar *)malloc(n);
|
||||||
if (unlikely(!buf))
|
if (unlikely(!buf))
|
||||||
fatal("Failed to malloc match buffer of size %lld\n", n);
|
fatal("Failed to malloc match buffer of size %lld\n", n);
|
||||||
|
|
||||||
|
|
|
||||||
4
stream.c
4
stream.c
|
|
@ -606,7 +606,7 @@ ssize_t write_1g(int fd, void *buf, i64 len)
|
||||||
else
|
else
|
||||||
ret = len;
|
ret = len;
|
||||||
ret = write(fd, offset_buf, (size_t)ret);
|
ret = write(fd, offset_buf, (size_t)ret);
|
||||||
if (unlikely(ret < 0))
|
if (unlikely(ret <= 0))
|
||||||
return ret;
|
return ret;
|
||||||
len -= ret;
|
len -= ret;
|
||||||
offset_buf += ret;
|
offset_buf += ret;
|
||||||
|
|
@ -629,7 +629,7 @@ ssize_t read_1g(int fd, void *buf, i64 len)
|
||||||
else
|
else
|
||||||
ret = len;
|
ret = len;
|
||||||
ret = read(fd, offset_buf, (size_t)ret);
|
ret = read(fd, offset_buf, (size_t)ret);
|
||||||
if (unlikely(ret < 0))
|
if (unlikely(ret <= 0))
|
||||||
return ret;
|
return ret;
|
||||||
len -= ret;
|
len -= ret;
|
||||||
offset_buf += ret;
|
offset_buf += ret;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue