changeset 63:355800cdefcc

Use correct remaining size for strncpy
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 18 Mar 2014 14:11:34 +0000
parents aa707f111e89
children fb9f78f7ab2f
files common/strhelp.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/common/strhelp.c	Tue Mar 18 14:07:03 2014 +0000
+++ b/common/strhelp.c	Tue Mar 18 14:11:34 2014 +0000
@@ -78,9 +78,9 @@
     } else {
         size_t old_len = strlen(*pDst);
         size_t new_len = old_len + len + 1;
-        *pDst = (char *)xrealloc(*pDst, sizeof(char) * (new_len));
-        strncpy(*pDst + old_len, appendage, new_len);
-        *pDst[new_len] = '\0';
+        *pDst = (char *)xrealloc(*pDst, sizeof(char) * (new_len + 1));
+        strncpy(*pDst + old_len, appendage, len);
+        (*pDst)[new_len] = '\0';
     }
 }
 

http://wald.intevation.org/projects/trustbridge/