File: java/rocksjni/transaction_db.cc
Function: Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3J
The database path is acquired with GetStringUTFChars and every return path before TransactionDB::Open releases it — but none of the paths after Open do, so the string is leaked on the normal (and failure) paths.
const char* db_path = env->GetStringUTFChars(jdb_path, nullptr); // ~line 63
if (db_path == nullptr) { // OOM
return nullptr;
}
// ... column-family argument conversion ...
// each early failure branch does: env->ReleaseStringUTFChars(jdb_path, db_path);
const ROCKSDB_NAMESPACE::Status s = ROCKSDB_NAMESPACE::TransactionDB::Open(
*db_options, *txn_db_options, db_path, column_families, &handles, &tdb); // ~line 114
if (s.ok()) {
// ... builds jresults, with two `return nullptr` paths and `return jresults` ...
return jresults; // db_path NOT released
} else {
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, s);
return nullptr; // db_path NOT released
}
A successful GetStringUTFChars must be paired with ReleaseStringUTFChars: the JVM may return a freshly allocated modified-UTF-8 copy, or pin string storage. The early argument-conversion failures correctly release db_path; all of the paths reached once TransactionDB::Open has been called (the success return jresults, its two intermediate return nullptr paths, and the Open-failure ThrowNew path) omit the release. So db_path is leaked on every normal open and on post-Open failures.
File:
java/rocksjni/transaction_db.ccFunction:
Java_org_rocksdb_TransactionDB_open__JJLjava_lang_String_2_3_3B_3JThe database path is acquired with
GetStringUTFCharsand every return path beforeTransactionDB::Openreleases it — but none of the paths afterOpendo, so the string is leaked on the normal (and failure) paths.A successful
GetStringUTFCharsmust be paired withReleaseStringUTFChars: the JVM may return a freshly allocated modified-UTF-8 copy, or pin string storage. The early argument-conversion failures correctly releasedb_path; all of the paths reached onceTransactionDB::Openhas been called (the successreturn jresults, its two intermediatereturn nullptrpaths, and theOpen-failureThrowNewpath) omit the release. Sodb_pathis leaked on every normal open and on post-Openfailures.