From 45800a25e9374e63caaabba05c89585c86acd668 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 28 Dec 2015 19:22:37 +0000 Subject: db_lmdb: fix a strdup/delete[] mistmatch --- src/blockchain_db/lmdb/db_lmdb.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 325ed8b8c..ded648cae 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -130,13 +130,16 @@ private: template<> struct MDB_val_copy: 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 data; }; -- cgit v1.2.3