| Summary: | Freeing an uninitialized pointer. (pkg->tags) | ||
|---|---|---|---|
| Product: | [Yocto Project Subprojects] opkg | Reporter: | lnksz.dev |
| Component: | opkg | Assignee: | Alejandro del Castillo <alejandro.delcastillo> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | minor | ||
| Priority: | Undecided | ||
| Version: | 1.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Don't know | |
Applied patch on 7e032d8720b34722b3d9be732cb8620912e4dc96 |
Freeing an uninitialized pointer. ```c pkg_t pkg; pkg_init_from_file(&next, "/tmp/some.ipk"); // This calls pkg_init() under the hood // Use pkg here pkg_deinit(&pkg); // ==> free(pkg->tags) freeing an uninitialized pointer ``` This is not surfacing if one uses the pkg_new() call, as the underlaying calloc() sets this to 0, which could be NULL, so the free is ok. But as the described method is also legit by the API and spares a possible memory leak, the init should be added. patch: ``` --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -85,6 +85,7 @@ pkg_init(pkg_t *pkg) pkg->maintainer = NULL; pkg->section = NULL; pkg->description = NULL; + pkg->tags = NULL; pkg->state_want = SW_UNKNOWN; pkg->wanted_by = pkg_vec_alloc(); pkg->state_flag = SF_OK; ```