comparison 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
comparison
equal deleted inserted replaced
62:aa707f111e89 63:355800cdefcc
76 if (!*pDst) { 76 if (!*pDst) {
77 *pDst = xstrndup(appendage, len); 77 *pDst = xstrndup(appendage, len);
78 } else { 78 } else {
79 size_t old_len = strlen(*pDst); 79 size_t old_len = strlen(*pDst);
80 size_t new_len = old_len + len + 1; 80 size_t new_len = old_len + len + 1;
81 *pDst = (char *)xrealloc(*pDst, sizeof(char) * (new_len)); 81 *pDst = (char *)xrealloc(*pDst, sizeof(char) * (new_len + 1));
82 strncpy(*pDst + old_len, appendage, new_len); 82 strncpy(*pDst + old_len, appendage, len);
83 *pDst[new_len] = '\0'; 83 (*pDst)[new_len] = '\0';
84 } 84 }
85 } 85 }
86 86
87 void 87 void
88 strfreev (char **str_array) 88 strfreev (char **str_array)

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