speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH (speechd) 1/4] Insure free in spd_execute_command_with_reply.


From: Christopher Brannon
Subject: [PATCH (speechd) 1/4] Insure free in spd_execute_command_with_reply.
Date: Fri, 19 Feb 2010 09:50:09 -0600

This function could leak memory on an error condition.
I moved the xfree call, so that the buffer is freed as soon as it is
no longer needed.
---
 src/c/api/libspeechd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/c/api/libspeechd.c b/src/c/api/libspeechd.c
index 752a9b6..a4f8fb8 100644
--- a/src/c/api/libspeechd.c
+++ b/src/c/api/libspeechd.c
@@ -980,13 +980,13 @@ spd_execute_command_with_reply(SPDConnection *connection, 
char* command, char **
 
     buf = g_strdup_printf("%s\r\n", command);
     *reply = spd_send_data_wo_mutex(connection, buf, SPD_WAIT_REPLY);
+    xfree(buf);
+    buf = NULL;
     if(*reply==NULL){
         SPD_DBG("Can't send data wo mutex in spd_execute_command_with_reply");
        return -1;
     }
 
-    xfree(buf);
-    
     r = ret_ok(*reply);
 
     if (!r) return -1;
-- 
1.6.6.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]