The opkg_remove_dependent_pkgs() function will trigger a pkg_vec_free() and
break the loop when an error is returned by opkg_remove_pkg().
Since the vector is freed anyway after the loop, a double free occurs,
leading to a segmentation fault.
This situation commonly happens when recursively deleting packages in
conjunction with --autoremove where dependent packages might already have
been removed by previous iterations.
Simply break the loop without prematurely freeing the vector to fix this.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
for (i = 0; i < dependent_pkgs->len; i++) {
err = opkg_remove_pkg(dependent_pkgs->pkgs[i],0);
if (err) {
- pkg_vec_free(dependent_pkgs);
break;
}
}