summaryrefslogtreecommitdiff
path: root/count-delta.c
diff options
context:
space:
mode:
Diffstat (limited to 'count-delta.c')
-rw-r--r--count-delta.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/count-delta.c b/count-delta.c
index 3bcc205..e10c832 100644
--- a/count-delta.c
+++ b/count-delta.c
@@ -88,5 +88,8 @@ unsigned long count_delta(void *delta_buf, unsigned long delta_size)
/* delete size is what was _not_ copied from source.
* edit size is that and literal additions.
*/
+ if (src_size + added_literal < copied_from_source)
+ /* we ended up overcounting and underflowed */
+ return 0;
return (src_size - copied_from_source) + added_literal;
}