From bd8efe2f91761df866489c16e1c17870a8c88c5f Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Wed, 11 Aug 2021 21:12:46 +0800 Subject: [PATCH] [C][Client] Allocate memory for the element of array when the type is number (#10124) --- .../src/main/resources/C-libcurl/model-body.mustache | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache index a962081a46d..ae52b8c30b1 100644 --- a/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache +++ b/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache @@ -666,7 +666,13 @@ fail: { goto end; } - list_addElement({{{name}}}List , &{{{name}}}_local->valuedouble); + double *{{{name}}}_local_value = (double *)calloc(1, sizeof(double)); + if(!{{{name}}}_local_value) + { + goto end; + } + *{{{name}}}_local_value = {{{name}}}_local->valuedouble; + list_addElement({{{name}}}List , {{{name}}}_local_value); {{/isNumeric}} {{#isBoolean}} if(!cJSON_IsBool({{{name}}}_local))