aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-28 19:22:37 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-28 19:22:37 +0000
commit45800a25e9374e63caaabba05c89585c86acd668 (patch)
tree3399230d8681ed23c5b73cfb77dd867f3e5079bd /src/blockchain_db/lmdb
parentMerge pull request #565 (diff)
downloadmonero-45800a25e9374e63caaabba05c89585c86acd668.tar.xz
db_lmdb: fix a strdup/delete[] mistmatch
Diffstat (limited to 'src/blockchain_db/lmdb')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp9
1 files 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<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;
};