If this is called on an errored-out or freed iterator, it's meant to do
nothing, just like free(). Instead, it dereferences a null pointer due
to a couple of early tests being done in the wrong order.
Fix that.
libctf/
* ctf-hash.c (ctf_dynhash_next_remove): Check for null iterator
before dereferencing it.
{
ctf_next_t *i = *it;
- if ((void (*) (void)) ctf_dynhash_next != i->ctn_iter_fun)
- return ECTF_NEXT_WRONGFUN;
-
if (!i)
return ECTF_NEXT_END;
+ if ((void (*) (void)) ctf_dynhash_next != i->ctn_iter_fun)
+ return ECTF_NEXT_WRONGFUN;
+
if (i->ctn_n == 0)
return ECTF_NEXT_END;