speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 1/2] fix memory leak in spd_execute_command_with_list_reply while


From: Andrei Kholodnyi
Subject: [PATCH 1/2] fix memory leak in spd_execute_command_with_list_reply while returning w/o free
Date: Thu, 21 Oct 2010 21:54:04 +0200

if return code was not ok after spd_execute_command_with_reply call,
function returned w/o freed of previously allocated result.
Now allocation is moved after this function call
---
 src/api/c/libspeechd.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/api/c/libspeechd.c b/src/api/c/libspeechd.c
index e35d52d..6fc71b2 100644
--- a/src/api/c/libspeechd.c
+++ b/src/api/c/libspeechd.c
@@ -1138,11 +1138,11 @@ spd_execute_command_with_list_reply(SPDConnection 
*connection, char *command)
   char **result;
   int i, ret;
 
-  result = malloc((max_items+1)*sizeof(char*));
-
   ret = spd_execute_command_with_reply(connection, command, &reply);
   if(!ret_ok(reply)) return NULL;
-  
+
+  result = malloc((max_items+1)*sizeof(char*));
+
   for(i=0;  ;i++){
     line = get_param_str(reply, i+1, &err);
     if ((err) || (line == NULL)) break;
-- 
1.6.0.4




reply via email to

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