Compare commits

...

2 Commits

Author SHA1 Message Date
Olek
8449c6c365 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.
2025-11-21 22:20:45 +00:00
Vito Tumas
58e03190ac docs: Improve VaultWithdraw documentation (#6068) 2025-11-21 16:59:12 -05:00
4 changed files with 14 additions and 5 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -121,6 +121,8 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx)
if (auto const ret = checkFrozen(ctx.view, dstAcct, vaultAsset))
return ret;
// Cannot return shares to the vault, if the underlying asset was frozen for
// the submitter
if (auto const ret = checkFrozen(ctx.view, account, vaultShare))
return ret;