1.1 --- a/templates/native/buffer.c Sat Feb 11 15:34:30 2017 +0100
1.2 +++ b/templates/native/buffer.c Sat Feb 11 16:04:40 2017 +0100
1.3 @@ -1,6 +1,6 @@
1.4 /* Native functions for buffer operations.
1.5
1.6 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -37,7 +37,7 @@
1.12
1.13 /* Calculate the size of the string. */
1.14 for (i = 0; i < data->size; i++)
1.15 - size += __load_via_object(data->attrs[i].value, __pos___data__).size;
1.16 + size += strlen(__load_via_object(data->attrs[i].value, __pos___data__).strvalue);
1.17
1.18 /* Reserve space for a new string. */
1.19 s = (char *) __ALLOCATE(size + 1, sizeof(char));
1.20 @@ -46,13 +46,13 @@
1.21 for (i = 0, j = 0; i < data->size; i++)
1.22 {
1.23 o = __load_via_object(data->attrs[i].value, __pos___data__);
1.24 - n = o.size;
1.25 + n = strlen(o.strvalue);
1.26 memcpy(s + j, o.strvalue, n); /* does not null terminate but final byte should be zero */
1.27 j += n;
1.28 }
1.29
1.30 /* Return a new string. */
1.31 - return __new_str(s, size);
1.32 + return __new_str(s);
1.33 }
1.34
1.35 /* Module initialisation. */