Usually the PPI structure owns its own strdup'd copy of the pkgname string.
However, sometimes it shared it in a non-owning way with another structure
which risked the possibility of trying to use it after that other structure
had already been destroyed.
Change-Id: I71433d24137ef8e96325e9a2aeece53b51b079b5
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
}
if (pai->ai)
- ppi->pkgname = pai->ai->pkgname;
- else {
+ ppi->pkgname = strdup(pai->ai->pkgname);
+ else
ppi->pkgname = strndup(pkgname, strlen(pkgname)+1);
- if (!ppi->pkgname) {
- _E("Fail to add %s : not enough memory", pkgname);
- free(ppi);
- return NULL;
- }
+
+ if (!ppi->pkgname) {
+ _E("Fail to add %s : not enough memory", pkgname);
+ free(ppi);
+ return NULL;
}
proc_program_list = g_slist_prepend(proc_program_list, ppi);
_I("%s is added in the program info", pkgname);