mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-03 02:09:41 +00:00
index: fix potential memory leaks
This commit is contained in:
parent
9146f1e57e
commit
8d6ef4bf78
12
src/index.c
12
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;
|
||||
|
@ -325,7 +325,7 @@ static int hash_and_save(git_indexer_stream *idx, git_rawobj *obj, git_off_t ent
|
||||
/* FIXME: Parse the object instead of hashing it */
|
||||
if (git_odb__hashobj(&oid, obj) < 0) {
|
||||
giterr_set(GITERR_INDEXER, "Failed to hash object");
|
||||
return -1;
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
pentry = git__calloc(1, sizeof(struct git_pack_entry));
|
||||
|
Loading…
Reference in New Issue
Block a user