From b018ae643dbba21c0060ccb0748a7b239b4ecb5a Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Fri, 16 Jul 2021 21:11:36 +0800 Subject: Initialise items JSON before concatenating --- anteraja.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/anteraja.c b/anteraja.c index aad6d04..ad194f5 100644 --- a/anteraja.c +++ b/anteraja.c @@ -108,8 +108,10 @@ void anteraja_order(const char *trx_id, const char *service, const char *sender_ atoi(items[i][PRICE]), atoi(items[i][WEIGHT]) * 1000); if (json) json = realloc(json, strlen(json) + length); - else + else { json = malloc(length); + memset(json, '\0', strlen(json)); + } strcat(json, item); if (i + 1 < nitems) json[length] = ','; -- cgit v1.3