If there are no parameters, there is nothing to validate.
If params == NULL, memcpy below results in memcpy(sorted, NULL, 0),
which is UB.
Found by UBSAN. Example of this codepath: virDomainBlockCopy()
(where nparams == 0 is valid) -> qemuDomainBlockCopy()
Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
g_autofree virTypedParameterPtr sorted = NULL;
g_autofree virTypedParameterPtr keys = NULL;
+ if (!nparams) {
+ return 0;
+ }
+
va_start(ap, nparams);
sorted = g_new0(virTypedParameter, nparams);