Skip to content

Commit

Permalink
db_lmdb: fix a strdup/delete[] mistmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
moneromooo-monero committed Dec 28, 2015
1 parent 95ceb71 commit 45800a2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ struct MDB_val_copy<cryptonote::blobdata>: public MDB_val
template<>
struct MDB_val_copy<const char*>: public MDB_val
{
MDB_val_copy(const char *s) :
data(strdup(s))
MDB_val_copy(const char *s):
len(strlen(s)),
data(new char[len+1])
{
mv_size = strlen(s) + 1; // include the NUL, makes it easier for compares
memcpy(data.get(), s, len+1);
mv_size = len + 1; // include the NUL, makes it easier for compares
mv_data = data.get();
}
private:
size_t len;
std::unique_ptr<char[]> data;
};

Expand Down

0 comments on commit 45800a2

Please sign in to comment.