From e8a952561c4e59ca308d1973de46fc32ad91a022 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 4 Jan 2010 18:57:13 +0000 Subject: msvc: Fix some -W4 warnings Signed-off-by: Ramsay Jones --- src/delta-apply.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/delta-apply.c') diff --git a/src/delta-apply.c b/src/delta-apply.c index 7b592ecfb..4915947ac 100644 --- a/src/delta-apply.c +++ b/src/delta-apply.c @@ -9,7 +9,8 @@ * Nicolas Pitre . */ -static size_t hdr_sz( +static int hdr_sz( + size_t *size, const unsigned char **delta, const unsigned char *end) { @@ -25,7 +26,8 @@ static size_t hdr_sz( shift += 7; } while (c & 0x80); *delta = d; - return r; + *size = r; + return 0; } int git__delta_apply( @@ -36,17 +38,19 @@ int git__delta_apply( size_t delta_len) { const unsigned char *delta_end = delta + delta_len; - size_t res_sz; + size_t base_sz, res_sz; unsigned char *res_dp; /* Check that the base size matches the data we were given; * if not we would underflow while accessing data from the * base object, resulting in data corruption or segfault. */ - if (base_len != hdr_sz(&delta, delta_end)) + if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) + return GIT_ERROR; + + if (hdr_sz(&res_sz, &delta, delta_end) < 0) return GIT_ERROR; - res_sz = hdr_sz(&delta, delta_end); if ((res_dp = git__malloc(res_sz + 1)) == NULL) return GIT_ERROR; res_dp[res_sz] = '\0'; -- cgit v1.2.1