X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=count-delta.c;h=e10c832a758f49e9117a3456686d54f8b94ce10b;hb=65c2e0c349aa5c7f605defb52dc67f1b3658a1b9;hp=3bcc205f5131a168ac71d9b011d11920e25736f8;hpb=844e6e4d58d3e52eee7fb490bfaeadaa5ea2d59c;p=git.git diff --git a/count-delta.c b/count-delta.c index 3bcc205f..e10c832a 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; }