Commit 313c6d61 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

pstree: check if thread core is allocated before freeing

It looks like, it's possible that cores for some threads
were allocated, but not for all - allocation failed in
pstree_alloc_cores(). And after that we will dereference
NULL pointer as pstree_free_cores() doesn't check pointer:

pstree.c:28:6: warning: Access to field 'tc' results in a dereference of a null pointer (loaded from variable 'core')
        if (core->tc && core->tc->timers)
            ^~~~~~~~
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 0d45dd69
...@@ -163,7 +163,8 @@ void pstree_free_cores(struct pstree_item *item) ...@@ -163,7 +163,8 @@ void pstree_free_cores(struct pstree_item *item)
if (item->core) { if (item->core) {
for (i = 1; i < item->nr_threads; i++) for (i = 1; i < item->nr_threads; i++)
core_entry_free(item->core[i]); if (item->core[i])
core_entry_free(item->core[i]);
xfree(item->core); xfree(item->core);
item->core = NULL; item->core = NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment