From 63b762a62741aad7c0387b7209519867b44b7977 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 17 Feb 2019 15:34:14 +0100 Subject: [PATCH] missing nul-termination triggers valgrind. --- src/json.test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/json.test.c b/src/json.test.c index 30d4e072e..ec814eec6 100644 --- a/src/json.test.c +++ b/src/json.test.c @@ -58,6 +58,7 @@ static cJSON *export_a_region(CuTest * tc, const struct terrain_type *terrain, r int err; region *r; cJSON *json, *attr, *result, *regs; + size_t sz; r = test_create_region(0, 0, terrain); @@ -65,7 +66,8 @@ static cJSON *export_a_region(CuTest * tc, const struct terrain_type *terrain, r err = json_export(&out, EXPORT_REGIONS); CuAssertIntEquals(tc, 0, err); out.api->rewind(out.handle); - out.api->read(out.handle, buf, sizeof(buf)); + sz = out.api->read(out.handle, buf, sizeof(buf)); + buf[sz] = '\0'; mstream_done(&out); json = cJSON_Parse(buf);