There are 2 bugs in virTypedParamsValidateTemplate's counting of the
passed amount of templates:
- the condition looked for empty strings rather than non-empty ones
- the count was 1 more than the amount of templates due to use of
post-increment directly in the condition
Fixes: 45617351585caa2c5bcc51af48bd32fd750e7afd
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/880
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
/* we need to copy the list of templates because
* 'virTypedParamsValidateInternal' will need to sort it */
- while (*templates[ntemplates++].name == '\0')
- ;
+ while (*templates[ntemplates].name != '\0')
+ ntemplates++;
templ_copy = g_new0(virTypedParamValidationTemplate, ntemplates);
memcpy(templ_copy, templates, sizeof(*templates) * ntemplates);