core: Zero out unused entries when extending ptr_table array in ptr_table__add()
Otherwise we may end up accessing invalid pointers and crashing. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d133569bd0
commit
5a85d9a450
|
@ -452,6 +452,10 @@ static int ptr_table__add(struct ptr_table *pt, void *ptr, uint32_t *idxp)
|
|||
if (entries == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Zero out the new range */
|
||||
memset(entries + pt->allocated_entries * sizeof(void *), 0,
|
||||
(allocated_entries - pt->allocated_entries) * sizeof(void *));
|
||||
|
||||
pt->allocated_entries = allocated_entries;
|
||||
pt->entries = entries;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue