]> 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)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 29 Jun 2021 07:38:57 +0000 (09:38 +0200)
commit7c2e8e16beb3bf3c3f4b9b66580c48c88a54b68d
tree584eac60be82858dd325f783f456a718da4c113c
parentdfdf49268ecdf4449c424325e4924093116d097b
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