Skip to content

Commit

Permalink
null check dynamic casts (#4548)
Browse files Browse the repository at this point in the history
# Description

Resolves stellar/stellar-core-internal#307

Checks for null after dynamic casting pointers.

# Checklist
- [x] Reviewed the
[contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes)
document
- [x] Rebased on top of master (no merge commits)
- [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio
extension)
- [x] Compiles
- [x] Ran all tests
- [ ] If change impacts performance, include supporting evidence per the
[performance
document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
  • Loading branch information
marta-lokhova authored Nov 21, 2024
2 parents 1f5ab3e + bdd99db commit 4b4cd36
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnAccountSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ class BulkLoadAccountsOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnClaimableBalanceSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class BulkLoadClaimableBalanceOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnConfigSettingSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class bulkLoadConfigSettingsOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnContractCodeSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class BulkLoadContractCodeOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnContractDataSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BulkLoadContractDataOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnDataSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ class BulkLoadDataOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnLiquidityPoolSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class BulkLoadLiquidityPoolOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnOfferSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ class BulkLoadOffersOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnTTLSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class BulkLoadTTLOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down
1 change: 1 addition & 0 deletions src/ledger/LedgerTxnTrustLineSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class BulkLoadTrustLinesOperation
}
auto sqliteStatement =
dynamic_cast<soci::sqlite3_statement_backend*>(be);
releaseAssertOrThrow(sqliteStatement);
auto st = sqliteStatement->stmt_;

sqlite3_reset(st);
Expand Down

0 comments on commit 4b4cd36

Please sign in to comment.