summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-13 09:59:00 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-10-13 20:59:49 +0100
commit15decb9b323029e764a89a78793862c8af74cbac (patch)
tree89bf6c1c8abf05e4227c832056a761f8f100bdf1 /connectivity
parentaffd907cb4f19d006efc5cbde903970d7f97ef46 (diff)
coverity#1158396 Uncaught exception
Change-Id: I0306b8431641d841027b30dfe1c03ecad5df6867
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Blob.cxx7
-rw-r--r--connectivity/source/drivers/firebird/Util.cxx56
-rw-r--r--connectivity/source/drivers/firebird/Util.hxx14
3 files changed, 47 insertions, 30 deletions
diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
index 7d62bbc7da5f..44cd33e58e79 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -212,8 +212,11 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
&nBytesRead,
nReadSize,
(char*) rDataOut.getArray() + nTotalBytesRead);
- if (aErr)
- evaluateStatusVector(m_statusVector, "isc_get_segment", *this);
+ if (aErr && IndicatesError(m_statusVector))
+ {
+ OUString sError(StatusVectorToString(m_statusVector, "isc_get_segment"));
+ throw IOException(sError, *this);
+ }
nTotalBytesRead += nBytesRead;
m_nBlobPosition += nBytesRead;
}
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index 448fa3ab2f43..0806d0e987f1 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -26,37 +26,43 @@ OUString firebird::sanitizeIdentifier(const OUString& rIdentifier)
return sRet;
}
-void firebird::evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector,
- const OUString& aCause,
- const uno::Reference< XInterface >& _rxContext)
- throw(SQLException)
+OUString firebird::StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector,
+ const OUString& rCause)
{
- if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
- {
- OUStringBuffer buf;
- char msg[512]; // Size is based on suggestion in docs.
- const ISC_STATUS* pStatus = (const ISC_STATUS*) &aStatusVector;
+ OUStringBuffer buf;
+ char msg[512]; // Size is based on suggestion in docs.
+ const ISC_STATUS* pStatus = (const ISC_STATUS*) &rStatusVector;
- buf.appendAscii("firebird_sdbc error:");
- try
- {
- while(fb_interpret(msg, sizeof(msg), &pStatus))
- {
- // TODO: verify encoding
- buf.appendAscii("\n*");
- buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
- }
- }
- catch (...)
+ buf.appendAscii("firebird_sdbc error:");
+ try
+ {
+ while(fb_interpret(msg, sizeof(msg), &pStatus))
{
- SAL_WARN("connectivity.firebird", "ignore fb_interpret exception");
+ // TODO: verify encoding
+ buf.appendAscii("\n*");
+ buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
}
- buf.appendAscii("\ncaused by\n'").append(aCause).appendAscii("'\n");
+ }
+ catch (...)
+ {
+ SAL_WARN("connectivity.firebird", "ignore fb_interpret exception");
+ }
+ buf.appendAscii("\ncaused by\n'").append(rCause).appendAscii("'\n");
- OUString error = buf.makeStringAndClear();
- SAL_WARN("connectivity.firebird", error);
+ OUString error = buf.makeStringAndClear();
+ SAL_WARN("connectivity.firebird", error);
+ return error;
+}
- throw SQLException( error, _rxContext, OUString(), 1, Any() );
+void firebird::evaluateStatusVector(const ISC_STATUS_ARRAY& rStatusVector,
+ const OUString& rCause,
+ const uno::Reference< XInterface >& _rxContext)
+ throw(SQLException)
+{
+ if (IndicatesError(rStatusVector))
+ {
+ OUString error = StatusVectorToString(rStatusVector, rCause);
+ throw SQLException(error, _rxContext, OUString(), 1, Any());
}
}
diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx
index e6a978aca84b..c04488f342d7 100644
--- a/connectivity/source/drivers/firebird/Util.hxx
+++ b/connectivity/source/drivers/firebird/Util.hxx
@@ -31,13 +31,21 @@ namespace connectivity
* for such shorter strings, however any trailing padding makes the gui
* editing of such names harder, hence we remove all trailing whitespace.
*/
- ::rtl::OUString sanitizeIdentifier(const ::rtl::OUString& rIdentifier);
+ OUString sanitizeIdentifier(const OUString& rIdentifier);
+
+ inline bool IndicatesError(const ISC_STATUS_ARRAY& rStatusVector)
+ {
+ return rStatusVector[0]==1 && rStatusVector[1]; // indicates error;
+ }
+
+ OUString StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector,
+ const OUString& rCause);
/**
* Evaluate a firebird status vector and throw exceptions as necessary.
* The content of the status vector is included in the thrown exception.
*/
- void evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector,
+ void evaluateStatusVector(const ISC_STATUS_ARRAY& rStatusVector,
const ::rtl::OUString& aCause,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext)
throw (::com::sun::star::sdbc::SQLException);
@@ -60,4 +68,4 @@ namespace connectivity
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_UTIL_HXX
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */