Merge pull request #461 from fyrz/RocksJava-DirectSlice-Fix

[RocksJava] DirectSlice String termination fix
This commit is contained in:
Yueh-Hsuan Chiang 2015-01-17 09:08:50 -08:00
commit 1190ebe5aa

View File

@ -29,8 +29,9 @@ void Java_org_rocksdb_AbstractSlice_createNewSliceFromString(
const auto* str = env->GetStringUTFChars(jstr, 0); const auto* str = env->GetStringUTFChars(jstr, 0);
const size_t len = strlen(str); const size_t len = strlen(str);
char* buf = new char[len]; char* buf = new char[len + 1];
memcpy(buf, str, len); memcpy(buf, str, len);
buf[len] = 0;
env->ReleaseStringUTFChars(jstr, str); env->ReleaseStringUTFChars(jstr, str);
const auto* slice = new rocksdb::Slice(buf); const auto* slice = new rocksdb::Slice(buf);