Rohit Ashiwal <rohit.ashiwal265@xxxxxxxxx> writes: > + if (name) > + *name = kv.items[name_i].util; > + else > + free(kv.items[name_i].util); > + if (email) > + *email = kv.items[email_i].util; > + else > + free(kv.items[email_i].util); > + if (date) > + *date = kv.items[date_i].util; > + else > + free(kv.items[date_i].util); > retval = 0; Some of the .util field may have been freed and others may have taken possession by the caller at this point. > finish: > string_list_clear(&kv, !!retval); And we tell string_list_clear() not to free the .util field, so kv.items[].util won't leak, which is good.