diff options
author | Rémi Duraffort <ivoire@videolan.org> | 2013-07-15 15:59:35 +0200 |
---|---|---|
committer | Rémi Duraffort <ivoire@videolan.org> | 2013-07-15 16:29:09 +0200 |
commit | 8d6ef4bf78cc5d3a3cb277ecc4fcf0fdcdbc9f20 (patch) | |
tree | f1212f84f461e519b76c2681460f3144532a4f31 /src/index.c | |
parent | 9146f1e57ec4f2b6fa293c78d54f1383464ff5be (diff) | |
download | libgit2-8d6ef4bf78cc5d3a3cb277ecc4fcf0fdcdbc9f20.tar.gz |
index: fix potential memory leaks
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/index.c b/src/index.c index bd5e192f3..0610eb5b9 100644 --- a/src/index.c +++ b/src/index.c @@ -1409,14 +1409,18 @@ static int read_reuc(git_index *index, const char *buffer, size_t size) if (git__strtol32(&tmp, buffer, &endptr, 8) < 0 || !endptr || endptr == buffer || *endptr || - (unsigned)tmp > UINT_MAX) + (unsigned)tmp > UINT_MAX) { + index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry stage"); + } lost->mode[i] = tmp; len = (endptr + 1) - buffer; - if (size <= len) + if (size <= len) { + index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry stage"); + } size -= len; buffer += len; @@ -1426,8 +1430,10 @@ static int read_reuc(git_index *index, const char *buffer, size_t size) for (i = 0; i < 3; i++) { if (!lost->mode[i]) continue; - if (size < 20) + if (size < 20) { + index_entry_reuc_free(lost); return index_error_invalid("reading reuc entry oid"); + } git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer); size -= 20; |