mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 01:07:57 +00:00
Fix: nullptr resolving without db config (#6029)
If the config disables SQL db usage, such as a validator: ``` [ledger_tx_tables] use_tx_tables = 0 ``` then the pointer to DB engine is null, but it was still resolved during startup. Although it didn't crash in Release mode, possibly due to the compiler optimizing it away, it did crash in Debug mode. This change explicitly checks for the validity of the pointer and generates a runtime error if not set.
This commit is contained in:
@@ -171,7 +171,7 @@ getRowsMinMax(soci::session& session, TableType type)
|
||||
bool
|
||||
saveValidatedLedger(
|
||||
DatabaseCon& ldgDB,
|
||||
DatabaseCon& txnDB,
|
||||
std::unique_ptr<DatabaseCon> const& txnDB,
|
||||
Application& app,
|
||||
std::shared_ptr<Ledger const> const& ledger,
|
||||
bool current)
|
||||
@@ -254,7 +254,15 @@ saveValidatedLedger(
|
||||
|
||||
if (app.config().useTxTables())
|
||||
{
|
||||
auto db = txnDB.checkoutDb();
|
||||
if (!txnDB)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "TxTables db isn't available";
|
||||
Throw<std::runtime_error>("TxTables db isn't available");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
auto db = txnDB->checkoutDb();
|
||||
|
||||
soci::transaction tr(*db);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ getRowsMinMax(soci::session& session, TableType type);
|
||||
bool
|
||||
saveValidatedLedger(
|
||||
DatabaseCon& ldgDB,
|
||||
DatabaseCon& txnDB,
|
||||
std::unique_ptr<DatabaseCon> const& txnDB,
|
||||
Application& app,
|
||||
std::shared_ptr<Ledger const> const& ledger,
|
||||
bool current);
|
||||
|
||||
@@ -392,8 +392,7 @@ SQLiteDatabaseImp::saveValidatedLedger(
|
||||
{
|
||||
if (existsLedger())
|
||||
{
|
||||
if (!detail::saveValidatedLedger(
|
||||
*lgrdb_, *txdb_, app_, ledger, current))
|
||||
if (!detail::saveValidatedLedger(*lgrdb_, txdb_, app_, ledger, current))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user