diff options
| author | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-04-20 16:52:51 +0200 |
|---|---|---|
| committer | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2024-04-20 16:52:51 +0200 |
| commit | b736b3e465e2265711bd38289b202b7a4b0c2f02 (patch) | |
| tree | 575f14caec3588776e47db542a53680a617ab3b1 /monero_libwallet2_api_c/src/main | |
| parent | 162dfa6683f6205583468b94bf68ff4fc9de5daf (diff) | |
fix memory allocation issuev0.18.3.3-RC31
Diffstat (limited to 'monero_libwallet2_api_c/src/main')
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/helpers.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/monero_libwallet2_api_c/src/main/cpp/helpers.cpp b/monero_libwallet2_api_c/src/main/cpp/helpers.cpp index 3191390..3f7c66a 100644 --- a/monero_libwallet2_api_c/src/main/cpp/helpers.cpp +++ b/monero_libwallet2_api_c/src/main/cpp/helpers.cpp @@ -24,8 +24,11 @@ const char* vectorToString(const std::vector<std::string>& vec, const std::strin } result += vec.back(); // Append the last string without the separator - const char* cstr = result.c_str(); - return cstr; + std::string str = result; + const std::string::size_type size = str.size(); + char *buffer = new char[size + 1]; //we need extra char for NUL + memcpy(buffer, str.c_str(), size + 1); + return buffer; } const char* vectorToString(const std::vector<uint32_t>& vec, const std::string separator) { |
