Mercurial > trustbridge
diff common/strhelp.c @ 63:355800cdefcc
Use correct remaining size for strncpy
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 18 Mar 2014 14:11:34 +0000 |
parents | 6acb1dae6185 |
children | 80ab2168760f |
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'; } }