summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-16 21:11:36 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-16 21:11:36 +0800
commitb018ae643dbba21c0060ccb0748a7b239b4ecb5a (patch)
tree0c00ca1cb59c72e6054aca8e1f231df8d4a0e0e4
parentabe673f9ae7d9d23e92a188ade187ec020b1f67a (diff)
Initialise items JSON before concatenating
-rw-r--r--anteraja.c4
1 files changed, 3 insertions, 1 deletions
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] = ',';