[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 06/14] rpc: Avoid resource leak of 'socks' if any object append fails



---
 src/rpc/virnetserverservice.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index 61dd682..5deacaa 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;
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]