You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a codebase heavily relying on UCL (https://github.com/freebsd/pkg) there is a recurring programming error causing a memory leak involving ucl_iterate_object.
When the iteration is abandoned in-flight, the iterator itself is never freed.
E.g. (abbreviated)
ucl_object_iter_tit=NULL;
while ((cur=ucl_iterate_object(obj, &it, true))) {
if (error) {
return (EPKG_FATAL); // it is leaked here
}
}
Not in every context is it possible to introduce UCL_FREE (sizeof (*it), it);, also it is not evident that that this is the only thing that needs to be done with the iterator.
I suggest introducing ucl_iterate_object_end(ucl_object_iter_t *iter) that can be called before abandoning iteration which does whatever is needed to be done to close the iterator and free all its resources.
The text was updated successfully, but these errors were encountered:
In a codebase heavily relying on UCL (https://github.com/freebsd/pkg) there is a recurring programming error causing a memory leak involving
ucl_iterate_object
.When the iteration is abandoned in-flight, the iterator itself is never freed.
E.g. (abbreviated)
Not in every context is it possible to introduce
UCL_FREE (sizeof (*it), it);
, also it is not evident that that this is the only thing that needs to be done with the iterator.I suggest introducing
ucl_iterate_object_end(ucl_object_iter_t *iter)
that can be called before abandoning iteration which does whatever is needed to be done to close the iterator and free all its resources.The text was updated successfully, but these errors were encountered: