Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan committed Oct 20, 2023
1 parent b08c6f3 commit 3276269
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/interface/TWString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


#include <TrustWalletCore/TWString.h>

#include <TrezorCrypto/memzero.h>
#include <string>

TWString *_Nonnull TWStringCreateWithUTF8Bytes(const char *_Nonnull bytes) {
Expand Down Expand Up @@ -34,7 +36,9 @@ const char *_Nonnull TWStringUTF8Bytes(TWString *_Nonnull string) {
}

void TWStringDelete(TWString *_Nonnull string) {
auto* s = reinterpret_cast<const std::string*>(string);
auto *sConst = reinterpret_cast<const std::string*>(string);
auto *s = const_cast<std::string*>(sConst);
memzero(s->data(), s->size());
delete s;
}

Expand Down

0 comments on commit 3276269

Please sign in to comment.