Code

data: Fixed length of newly allocated array in concat().
authorSebastian Harl <sh@tokkee.org>
Mon, 20 Oct 2014 07:42:35 +0000 (09:42 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 20 Oct 2014 07:42:35 +0000 (09:42 +0200)
src/core/data.c

index 0e40474edaabab45e98b9dc30d31b2b244de33d9..1baeadafc2dfb79e65c933964e3111f157f36cca 100644 (file)
@@ -279,7 +279,7 @@ data_concat(const sdb_data_t *d1, const sdb_data_t *d2, sdb_data_t *res)
        }
        else if (d1->type & SDB_TYPE_ARRAY) {
                res->data.array.values = new;
-               res->data.array.length = len1 + len2;
+               res->data.array.length = d1->data.array.length + d2->data.array.length;
                if (copy_array_values(res, res, sdb_data_sizeof(res->type & 0xff))) {
                        /* this leaks already copied values but there's not much we can
                         * do and this should only happen if we're in trouble anyway */