diff options
author | Linquize <linquize@yahoo.com.hk> | 2013-08-31 18:22:50 +0800 |
---|---|---|
committer | Linquize <linquize@yahoo.com.hk> | 2013-08-31 18:22:50 +0800 |
commit | d45e9480e74c3c6249aea631394e1364b138e66e (patch) | |
tree | 13a3d5e7ebc8ad022259b093c02d4887a5c34ab9 /src/oid.c | |
parent | 0001c0231607bd8bc9b09bde6c1d7d0fb396565f (diff) | |
download | libgit2-d45e9480e74c3c6249aea631394e1364b138e66e.tar.gz |
oid: git_oid_shorten_add() sets GITERR_INVALID when OID set is full
Diffstat (limited to 'src/oid.c')
-rw-r--r-- | src/oid.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -369,8 +369,10 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid) bool is_leaf; node_index idx; - if (os->full) + if (os->full) { + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); return -1; + } if (text_oid == NULL) return os->min_length; @@ -396,12 +398,19 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid) node->tail = NULL; node = push_leaf(os, idx, git__fromhex(tail[0]), &tail[1]); - GITERR_CHECK_ALLOC(node); + if (node == NULL) { + if (os->full) + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); + return -1; + } } if (node->children[c] == 0) { - if (push_leaf(os, idx, c, &text_oid[i + 1]) == NULL) + if (push_leaf(os, idx, c, &text_oid[i + 1]) == NULL) { + if (os->full) + giterr_set(GITERR_INVALID, "Unable to shorten OID - OID set full"); return -1; + } break; } |