]> git.ipfire.org Git - thirdparty/lxc.git/commit
Resize array in remove_from_array() and fix a crash
authorTomasz Blaszczak <tomasz.blaszczak@consult.red>
Fri, 25 Jun 2021 10:04:49 +0000 (12:04 +0200)
committerTomasz Blaszczak <tomasz.blaszczak@consult.red>
Fri, 25 Jun 2021 11:16:24 +0000 (13:16 +0200)
commit5364ae41aaa4718853b41dd0d312555867b990f1
tree305210c5d7e3f82f08ee4e00b795a85aa1231c3f
parentfe444ea6bcfe65d58a4dc0bef0db0c3372ed12a5
Resize array in remove_from_array() and fix a crash

When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, allocated memory pointed by
the item (not the item itself) should be freed, successive items should
be left-shifted and the array realloc()ed again (size-1).

Additional changes:
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.blaszczak@consult.red>
src/lxc/lxccontainer.c