[RocksJava] DirectSlice String termination fix

DirectSlice fix for non terminated String copy. This lead sometimes
to problems with DirectSliceTest.
This commit is contained in:
fyrz 2015-01-14 21:36:43 +01:00
parent 0ddf5f73ec
commit d68e83c356

View file

@ -28,9 +28,11 @@ void Java_org_rocksdb_AbstractSlice_createNewSliceFromString(
JNIEnv* env, jobject jobj, jstring jstr) {
const auto* str = env->GetStringUTFChars(jstr, 0);
const size_t len = strlen(str);
const size_t len = strlen(str) + 1;
char* buf = new char[len];
memcpy(buf, str, len);
memcpy(buf, str, len - 1);
buf[len-1]='\0';
env->ReleaseStringUTFChars(jstr, str);
const auto* slice = new rocksdb::Slice(buf);