aboutsummaryrefslogtreecommitdiff
path: root/src/work.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/work.c')
-rw-r--r--src/work.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/work.c b/src/work.c
index fe4697a..1ef699d 100644
--- a/src/work.c
+++ b/src/work.c
@@ -125,7 +125,10 @@ process_file(const char *locl_filename, unsigned char **locl_buf)
for (;;) {
ptrdiff_t want = nw + st.st_blksize;
if (want > basecap) {
- /* TODO: Check for overflow (top bit set) */
+ if (want & (1 << (PTRDIFF_WIDTH - 1))) {
+ errno = EOVERFLOW;
+ cerr(EXIT_FATAL, "%s:", __func__);
+ }
basecap = (ptrdiff_t)stdc_bit_ceil((size_t)want);
if ((baseptr = realloc(baseptr, basecap)) == nullptr)
cerr(EXIT_FATAL, "realloc:");