Commit 433eb4d47af050ec306ef0bf47924c1d44cb5ed0

Stefan Sperling 2018-06-22T09:34:00

make data output param of got_object_idset_remove_random() optional

diff --git a/lib/object_idset.c b/lib/object_idset.c
index cce68c1..3b924d5 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -190,7 +190,8 @@ got_object_idset_remove_random(void **data, struct got_object_idset *set)
 	struct got_object_idset_element *entry, *tmp;
 	int i, n;
 
-	*data = NULL;
+	if (data)
+		*data = NULL;
 
 	if (set->nelem == 0)
 		return got_error(GOT_ERR_NO_OBJ);
@@ -200,7 +201,8 @@ got_object_idset_remove_random(void **data, struct got_object_idset *set)
 		TAILQ_FOREACH_SAFE(entry, &set->entries[i], entry, tmp) {
 			if (--n == 0) {
 				TAILQ_REMOVE(&set->entries[i], entry, entry);
-				*data = entry->data;
+				if (data)
+					*data = entry->data;
 				free(entry);
 				set->nelem--;
 				return NULL;