db_lmdb: fix a strdup/delete[] mistmatch

This commit is contained in:
moneromooo-monero 2015-12-28 19:22:37 +00:00
parent 95ceb715dc
commit 45800a25e9
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 6 additions and 3 deletions

View File

@ -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;
};