diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 106403c9e9507704e3ee2966c38ed4d82f2487a8..f3ce1575328f9d17c3dcf936380c7ef549c0a0ce 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -501,21 +501,18 @@ virTypedParamsFilter(virTypedParameterPtr params, const char *name, virTypedParameterPtr **ret) { - size_t i, alloc = 0, n = 0; + size_t i, n = 0; virCheckNonNullArgGoto(params, error); virCheckNonNullArgGoto(name, error); virCheckNonNullArgGoto(ret, error); - *ret = NULL; + if (VIR_ALLOC_N(*ret, nparams) < 0) + goto error; for (i = 0; i < nparams; i++) { if (STREQ(params[i].field, name)) { - if (VIR_RESIZE_N(*ret, alloc, n, 1) < 0) - goto error; - (*ret)[n] = ¶ms[i]; - n++; } }