api.c: prevent array out-of-bounds access in cgroup_create_template_group
In the function src/api.c/cgroup_create_template_group,
the loop condition:
while (tmp->controllers[i] != NULL) {
allows accessing tmp->controllers[MAX_MNT_ELEMENTS] if tmp->controllers
is full and lacks a terminating NULL.
Add explicit bounds checking (i < MAX_MNT_ELEMENTS) while maintaining
the NULL check. This ensures that there will never be reading past
the array boundaries regardless of its content.
Found by Linux Verification Center (linuxtesting.org) with SVACE.