From: John Ferlan Date: Wed, 9 Jan 2013 14:54:12 +0000 (-0500) Subject: rpc: Avoid resource leak of 'socks' if any object append fails X-Git-Tag: v1.0.2-rc1~159 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af3262e26f8e0022b8aefb2925aa7692ef431dd7;p=thirdparty%2Flibvirt.git rpc: Avoid resource leak of 'socks' if any object append fails --- diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index b39f0ef275..2e024e1d08 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -356,9 +356,6 @@ virJSONValuePtr virNetServerServicePreExecRestart(virNetServerServicePtr svc) if (!object) return NULL; - if (!(socks = virJSONValueNewArray())) - goto error; - if (virJSONValueObjectAppendNumberInt(object, "auth", svc->auth) < 0) goto error; if (virJSONValueObjectAppendBoolean(object, "readonly", svc->readonly) < 0) @@ -366,6 +363,9 @@ virJSONValuePtr virNetServerServicePreExecRestart(virNetServerServicePtr svc) if (virJSONValueObjectAppendNumberUint(object, "nrequests_client_max", svc->nrequests_client_max) < 0) goto error; + if (!(socks = virJSONValueNewArray())) + goto error; + if (virJSONValueObjectAppend(object, "socks", socks) < 0) { virJSONValueFree(socks); goto error;