freecwmp
[Top] [All Lists]

[PATCH 2/2] fix memory leaks in xml_prepare_inform_message

To: freecwmp@linux-mips.org
Subject: [PATCH 2/2] fix memory leaks in xml_prepare_inform_message
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Tue, 24 Jul 2012 16:44:13 +0200
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=B0gQ/2P7zqCUhyOfwWOWkGsUvg95UPsr7SJlLfST2yk=; b=0QEdgyf5iWZvX7ZI5tzFpZ20Jmzw8KmltFgy6TCvDuu8Hl/dji6n1eZeMBVW4LqI2Q Ay+F9qVn6pRKRplzeb6M6Cez8UdJrSThF8vzmyNceYtUf2ExixrruMEpTI2W4BpOv9g0 32D8Zqj9sECW1yZlCN8bjpMCqSeh94+i/uZrISPKbDI62WPFYgqI5BKzBgGWtVIdydog 6KE1rAuY016xhrWuWSkNBsEhgvAiPqD7qs5bjOCgnO7J5Hyt2HNo9ArNZAa58Ox4YWe3 FbktLC4XDWyIqTiCiK3h2s9vA+Eirm5qH1syJ3/TCvr/kZ0oKyDe+8tEUZZUHQvWFUGE z5QA==
In-reply-to: <1343141053-11739-1-git-send-email-jonas.gorski@gmail.com>
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <1343141053-11739-1-git-send-email-jonas.gorski@gmail.com>
Sender: freecwmp-bounce@linux-mips.org
Always free allocated value strings regardless of success of node
creation.

Contributed by T-Labs, Deutsche Telekom Innovation Laboratories

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 src/xml/xml.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xml/xml.c b/src/xml/xml.c
index 38f8583..8e46ee6 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -282,9 +282,9 @@ xml_prepare_inform_message(char **msg_out)
                goto error;
        if (c) {
                busy_node = mxmlNewText(busy_node, 0, c);
+               free(c);
                if (!busy_node)
                        goto error;
-               free(c);
        }
 
        tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
@@ -300,9 +300,9 @@ xml_prepare_inform_message(char **msg_out)
                goto error;
        if (c) {
                busy_node = mxmlNewText(busy_node, 0, c);
+               free(c);
                if (!busy_node)
                        goto error;
-               free(c);
        }
 
        *msg_out = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
-- 
1.7.10


<Prev in Thread] Current Thread [Next in Thread>