Sfoglia il codice sorgente

xmlrpc: clean allocated buffer

(cherry picked from commit ff712539566c903312ebba2f8e2585f9c80ffdcf)
(cherry picked from commit e1398e53e9825db6c20590e1576d960ac0c3c429)
(cherry picked from commit 1f6dc4df8572c07280478858087182f273c25fe3)
Daniel-Constantin Mierla 7 mesi fa
parent
commit
c51cc44b73
1 ha cambiato i file con 5 aggiunte e 2 eliminazioni
  1. 5 2
      src/modules/xmlrpc/xmlrpc.c

+ 5 - 2
src/modules/xmlrpc/xmlrpc.c

@@ -2019,7 +2019,7 @@ static int rpc_struct_printf(
 		struct rpc_struct *s, char *member_name, char *fmt, ...)
 {
 	int n, buf_size;
-	char *buf;
+	char *buf = NULL;
 	va_list ap;
 	str st, name;
 	struct xmlrpc_reply *reply;
@@ -2071,6 +2071,7 @@ static int rpc_struct_printf(
 			if(add_xmlrpc_reply(out, &member_suffix) < 0)
 				goto err;
 
+			mxr_free(buf);
 			return 0;
 		}
 		/* Else try again with more space. */
@@ -2085,6 +2086,8 @@ static int rpc_struct_printf(
 			goto err;
 		}
 	}
+	if(buf)
+		mxr_free(buf);
 	return 0;
 err:
 	if(buf)
@@ -2740,7 +2743,7 @@ static int ki_xmlrpc_reply(sip_msg_t *msg, int rcode, str *reason)
 		if(add_xmlrpc_reply(&reply, &int_suffix) < 0)
 			goto error;
 		if(add_xmlrpc_reply(&reply, &success_suffix) < 0)
-			return -1;
+			goto error;
 	}
 	if(send_reply(msg, &reply.body) < 0)
 		goto error;