From b018ae643dbba21c0060ccb0748a7b239b4ecb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= 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.2.3