You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix garbled diagnostic record on failed SQLDriverConnect
Every catch block that handled std::exception followed the same broken
pattern:
catch ( std::exception &ex ) {
SQLException &exception = (SQLException&)ex;
// virtual calls on `exception`...
}
The C-style cast is a reinterpret_cast. When the caught object was not
in fact a SQLException -- e.g. a std::bad_alloc, a raw FbException that
bypassed the IscDbc rewrap, or anything else that propagated out of
the IscDbc layer -- the subsequent virtual dispatch through `exception`
read through whatever bytes lay where SQLException's vtable pointer
would have been. On Linux that produced a diagnostic record with an
empty SQLSTATE, a non-deterministic native code, and a one-byte message
('[') whose reported length disagreed with its strlen.
This commit introduces a type-safe ExceptionInfo helper and a
postError(state, std::exception&) overload that route every catch
through dynamic_cast, falling back to std::exception::what() when the
caught object is not a SQLException. All 64 occurrences of the broken
pattern across OdbcConnection / OdbcStatement / OdbcDesc / OdbcEnv and
the Windows OdbcJdbcSetup tree are converted to the safe path.
The catch block in OdbcConnection::connect also gains a NULL guard
around connection->close(): if createConnection() throws before the
assignment, the previous code dereferenced a NULL pointer during
cleanup.
0 commit comments