Hello, Fix metadb_iterator_destroy() to accept NULL iterators.
This prevents potential crash in error handling, e.g. if memory allocation failed. -- Petr^2 Spacek
From 158e95e38e78cdeadf6ed6605b77dbaa754c657a Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Mon, 8 Jun 2015 14:05:55 +0200 Subject: [PATCH] Fix metadb_iterator_destroy() to accept NULL iterators. --- src/metadb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/metadb.c b/src/metadb.c index f4a1dea1a3039a6120be5a4b19d319376fce9fa0..797fcc9212c0a28b4a99a5bd964b257023a8d999 100644 --- a/src/metadb.c +++ b/src/metadb.c @@ -126,14 +126,14 @@ void metadb_iterator_destroy(metadb_iter_t **miterp) { metadb_iter_t *miter = NULL; - REQUIRE(miterp != NULL && *miterp != NULL); + REQUIRE(miterp != NULL); miter = *miterp; + if (miter == NULL) + return; + /* user has to deallocate state before calling destroy() */ INSIST(miter->state == NULL); - if (miter == NULL) - return; - if (miter->iter != NULL) dns_dbiterator_destroy(&miter->iter); -- 2.1.0
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code