From 3d0d8da998eea7db69b254f29b3bd2d255bf3217 Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Thu, 29 Sep 2022 12:02:49 +0800 Subject: char code[] wouldn't live outside the scope --- shopify.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shopify.c b/shopify.c index cd93bff..a8c2613 100644 --- a/shopify.c +++ b/shopify.c @@ -44,10 +44,8 @@ json_tokener_free(tokener);\ return MHD_NO;\ }\ - char code[strlen(postalcode) + 1];\ - code[0] = '\0';\ - strcpy(code, postalcode);\ - B = code;\ + B = malloc(strlen(postalcode) + 1);\ + strcpy(B, postalcode);\ } struct parameter { @@ -550,6 +548,8 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con, *upload_data_size = 0; char *json = carrierservice->rates(origin, destination, grams, session); + free(origin); + free(destination); if (!json) return MHD_NO; res = MHD_create_response_from_buffer( -- cgit v1.3