speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 2/2] free reply in spd_execute_command_with_list_reply


From: Andrei Kholodnyi
Subject: [PATCH 2/2] free reply in spd_execute_command_with_list_reply
Date: Thu, 21 Oct 2010 21:54:05 +0200

reply was not used but not freed when returned
---
 src/api/c/libspeechd.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/api/c/libspeechd.c b/src/api/c/libspeechd.c
index 6fc71b2..e70702b 100644
--- a/src/api/c/libspeechd.c
+++ b/src/api/c/libspeechd.c
@@ -1132,14 +1132,18 @@ spd_list_synthesis_voices(SPDConnection *connection)
 char**
 spd_execute_command_with_list_reply(SPDConnection *connection, char *command)
 {
-  char *reply, *line;
+  char *reply = NULL, *line;
   int err;
   int max_items = 50;
   char **result;
   int i, ret;
 
   ret = spd_execute_command_with_reply(connection, command, &reply);
-  if(!ret_ok(reply)) return NULL;
+  if(!ret_ok(reply)) {
+      if(reply != NULL)
+         free(reply);
+      return NULL;
+  }
 
   result = malloc((max_items+1)*sizeof(char*));
 
@@ -1154,7 +1158,8 @@ spd_execute_command_with_list_reply(SPDConnection 
*connection, char *command)
   }
 
   result[i] = NULL;
-  
+
+  free(reply);
   return result;
 }
 
-- 
1.6.0.4




reply via email to

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