commit - 2d5e8ac71a2823a61954bbb4e830f7ef01b20cba
commit + c0cca3f632d5afe2711669d320c2aa4809ea4abd
blob - ae64f9afe555ae449ffadfb4d39015675ba0b35b
blob + 1bd427826701c298c82bdf7f6c5770747fa61b82
--- lib/object_idset.c
+++ lib/object_idset.c
struct got_object_id *id)
{
struct got_object_idset_element *entry, *tmp;
- uint8_t i = id->sha1[0];
+ uint8_t i;
+ if (id)
+ i = id->sha1[0];
+ else
+ i = arc4random_uniform(nitems(set->entries));
+
if (set->nelem == 0)
return got_error(GOT_ERR_NO_OBJ);
TAILQ_FOREACH_SAFE(entry, &set->entries[i], entry, tmp) {
- if (got_object_id_cmp(&entry->id, id) == 0) {
+ if (id == NULL || got_object_id_cmp(&entry->id, id) == 0) {
TAILQ_REMOVE(&set->entries[i], entry, entry);
set->nelem--;
return NULL;