Merge pull request #461 from fyrz/RocksJava-DirectSlice-Fix
[RocksJava] DirectSlice String termination fix
This commit is contained in:
commit
1190ebe5aa
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user