if (!dst->data && !(dst->data = ast_str_create(src->data->used)))
return;
else if (dst->data->len < src->data->used)
- ast_str_make_space(&dst->data, src->data->used);
+ ast_str_make_space(&dst->data, src->data->used + 1); /* Account for null terminator needed */
- memcpy(dst->data->str, src->data->str, src->data->used);
+ ast_copy_string(dst->data->str, src->data->str, dst->data->len);
dst->data->used = src->data->used;
offset = ((void *)dst->data->str) - ((void *)src->data->str);
/* Now fix pointer arithmetic */
- for (x=0; x < src->headers; x++)
+ for (x = 0; x < src->headers; x++)
dst->header[x] += offset;
- for (x=0; x < src->lines; x++)
+ for (x = 0; x < src->lines; x++)
dst->line[x] += offset;
/* On some occasions this function is called without parse_request being called first so lets not create an invalid pointer */
if (src->rlPart1)
*/
struct ast_str {
size_t len; /*!< The current maximum length of the string */
- size_t used; /*!< Amount of space used */
+ size_t used; /*!< Amount of space used. Does not include string's null terminator */
struct ast_threadstorage *ts; /*!< What kind of storage is this ? */
#define DS_MALLOC ((struct ast_threadstorage *)1)
#define DS_ALLOCA ((struct ast_threadstorage *)2)