fix use vasprintf
Some checks failed
build-crpc / build (Debug, host.toolchain.cmake) (push) Has been cancelled
build-crpc / build (Release, host.toolchain.cmake) (push) Has been cancelled

This commit is contained in:
tqcq 2023-12-03 22:42:20 +08:00
parent 5e23c20364
commit 36280b0320

View File

@ -348,13 +348,14 @@ CServiceClientPlugin::GenerateSourceConnectFunctionDefinition(Service::Ptr servi
ss << " assert(format != NULL);" << std::endl; ss << " assert(format != NULL);" << std::endl;
ss << std::endl; ss << std::endl;
ss << " int32_t status = 0;" << 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_list args;" << std::endl;
ss << " va_start(args, format);" << 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 << " va_end(args);" << std::endl;
ss << std::endl; ss << std::endl;
ss << " status = Client_Connect(client->impl, address);" << 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 << " if (status != 0) { return status; }" << std::endl;
ss << std::endl; ss << std::endl;
ss << " Client_SetCallback(client->impl, " << service->id() << "_Client_Dispatch, client);" << std::endl; ss << " Client_SetCallback(client->impl, " << service->id() << "_Client_Dispatch, client);" << std::endl;