From 36280b0320983a10e07dc06723a34d3b0c6e6f13 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Sun, 3 Dec 2023 22:42:20 +0800 Subject: [PATCH] fix use vasprintf --- src/plugins/c/c_service_client_plugin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/c/c_service_client_plugin.cpp b/src/plugins/c/c_service_client_plugin.cpp index 3b66a00..31d15c6 100644 --- a/src/plugins/c/c_service_client_plugin.cpp +++ b/src/plugins/c/c_service_client_plugin.cpp @@ -348,13 +348,14 @@ CServiceClientPlugin::GenerateSourceConnectFunctionDefinition(Service::Ptr servi ss << " assert(format != NULL);" << std::endl; ss << std::endl; ss << " int32_t status = 0;" << std::endl; - ss << " char address[1024];" << std::endl; + ss << " char *address = NULL;" << std::endl; ss << " va_list args;" << std::endl; ss << " va_start(args, format);" << std::endl; - ss << " vsnprintf(address, sizeof(address), format, args);" << std::endl; + ss << " vasprintf(&address, format, args); " << std::endl; ss << " va_end(args);" << std::endl; ss << std::endl; ss << " status = Client_Connect(client->impl, address);" << std::endl; + ss << " free(address); " << std::endl; ss << " if (status != 0) { return status; }" << std::endl; ss << std::endl; ss << " Client_SetCallback(client->impl, " << service->id() << "_Client_Dispatch, client);" << std::endl;