changeset 31493:0a7222a42a70

Ensure that e.g. -af-pre will not cause the filter list to be unterminated when the list was empty before. Should fix bug #1687.
author reimar
date Fri, 25 Jun 2010 16:56:40 +0000
parents e4d6cf87aa06
children c92b055ebec7
files m_option.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/m_option.c	Fri Jun 25 16:53:27 2010 +0000
+++ b/m_option.c	Fri Jun 25 16:56:40 2010 +0000
@@ -485,10 +485,12 @@
   lst = realloc(lst,(n+ln+1)*sizeof(char*));
 
   if(pre) {
-    memmove(&lst[n],lst,(ln+1)*sizeof(char*));
+    memmove(&lst[n],lst,ln*sizeof(char*));
     memcpy(lst,add,n*sizeof(char*));
   } else
-    memcpy(&lst[ln],add,(n+1)*sizeof(char*));
+    memcpy(&lst[ln],add,n*sizeof(char*));
+  // (re-)add NULL-termination
+  lst[ln+n] = NULL;
 
   free(add);