summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2010-01-04 18:57:13 +0000
committerRamsay Jones <ramsay@ramsay1.demon.co.uk>2010-01-20 20:20:47 +0000
commite8a952561c4e59ca308d1973de46fc32ad91a022 (patch)
tree0fd7e4bfba5b3a82be88d1057757ca8b2c5e6d26 /src
parent1a7bae4d0f9d9314b905109b5b321219b7e6be3b (diff)
downloadlibgit2-e8a952561c4e59ca308d1973de46fc32ad91a022.tar.gz
msvc: Fix some -W4 warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/delta-apply.c14
-rw-r--r--src/fileops.c1
-rw-r--r--src/odb.c2
3 files changed, 11 insertions, 6 deletions
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 <nico@cam.org>.
*/
-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';
diff --git a/src/fileops.c b/src/fileops.c
index d1621f2e3..b3715dc1a 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -209,7 +209,6 @@ int gitfo_write_cached(gitfo_cache *ioc, void *buff, size_t len)
if (len > ioc->cache_size)
return gitfo_write(ioc->fd, buf, len);
}
- return GIT_SUCCESS;
}
int gitfo_close_cached(gitfo_cache *ioc)
diff --git a/src/odb.c b/src/odb.c
index afadc73a3..982cc52d0 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -840,6 +840,8 @@ static void packlist_dec(git_odb *db, git_packlist *pl)
{
int need_free;
+ assert(db && pl);
+
gitlck_lock(&db->lock);
need_free = !--pl->refcnt;
gitlck_unlock(&db->lock);