speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 3/5] Fix a nasty off-by-one bug in the Festival module.


From: Christopher Brannon
Subject: [PATCH 3/5] Fix a nasty off-by-one bug in the Festival module.
Date: Mon, 7 Jun 2010 12:08:47 -0500

A for loop in festival_client.c is supposed to iterate over a string,
copying everything that is not a parenthesis.
The comparison in the loop's test should be <, not <=.
Also, the statement that will append a NUL byte to the end of the copy
was wrong.  It was appending the number 0, rather than the character \0.
---
 src/modules/festival_client.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/modules/festival_client.c b/src/modules/festival_client.c
index ac2165d..a9e1b4e 100644
--- a/src/modules/festival_client.c
+++ b/src/modules/festival_client.c
@@ -712,23 +712,23 @@ int festivalClose(FT_Info *info)
 char**
 lisp_list_get_vect(char* expr)
 {
-  int len;
+  size_t len;
   char *helper;
   gchar **vect;
-  int i,j;
+  size_t i,j;
 
   len = strlen(expr);
-  helper = malloc(sizeof(char) * (len+1));
+  helper = xmalloc(sizeof(char) * (len+1));
 
   //Remove parenthesis
   j=0;
-  for (i=0; i<=len; i++){
+  for (i=0; i<len; i++){
     if ((expr[i] != '(') && (expr[i] != ')')){
       helper[j] = expr[i];
       j++;
     }
   }
-  helper[j]='0';
+  helper[j]='\0';
 
   // Split into a vector of atoms
   vect = g_strsplit(helper, " ", 0);
-- 
1.7.1




reply via email to

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