In sa_scf_init(), we have:
handle->scope = scf_scope_create(handle->handle);
handle->service = scf_service_create(handle->handle);
handle->pg = scf_pg_create(handle->handle);
handle->instance = scf_instance_create(handle->handle);
Besides the fact that it doesn't seem like we check the return
values for these functions, we also have the following in sa_scf_fini():
void
sa_scf_fini(scfutilhandle_t *handle)
{
if (handle != NULL) {
int unbind = 0;
if (handle->scope != NULL) {
unbind = 1;
scf_scope_destroy(handle->scope);
}
if (handle->service != NULL)
scf_service_destroy(handle->service);
if (handle->pg != NULL)
scf_pg_destroy(handle->pg);
if (handle->handle != NULL) {
handle->scf_state = SCH_STATE_UNINIT;
if (unbind)
(void) scf_handle_unbind(handle->handle);
scf_handle_destroy(handle->handle);
}
free(handle);
}
}
Notice that we never free 'instance' or 'scope'.