connectivity/source/drivers/jdbc/JStatement.cxx | 6 +++--- connectivity/source/drivers/odbc/OStatement.cxx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
New commits: commit b91cb7d137b5d8fd203bbdc1c4e3d0e851fd5aa6 Author: Jochen Nitschke <j.nitschke+loger...@ok.de> Date: Sat Jul 8 15:38:39 2017 +0200 cppcheck: uselessCallsRemove std::remove returns a past the end iterator which should be used for the reallocation. This makes the code more robust. Previously it only worked if there was exactly one value with type XGeneratedResultSet in the Sequence. Change-Id: Ia2db1252ba8fe682dbc55d9722eaa62ed596e297 Reviewed-on: https://gerrit.libreoffice.org/39724 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx index c89e3c4e6f51..fed0c3d7be15 100644 --- a/connectivity/source/drivers/jdbc/JStatement.cxx +++ b/connectivity/source/drivers/jdbc/JStatement.cxx @@ -133,9 +133,9 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes(); if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() ) { - std::remove(aOldTypes.begin(), aOldTypes.end(), - cppu::UnoType<XGeneratedResultSet>::get()); - aOldTypes.realloc(aOldTypes.getLength() - 1); + auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(), + cppu::UnoType<XGeneratedResultSet>::get()); + aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd)); } return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes); diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index 62ea7650590c..6a038b66c1a9 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -139,9 +139,9 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) Sequence< Type > aOldTypes = OStatement_BASE::getTypes(); if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() ) { - std::remove(aOldTypes.begin(), aOldTypes.end(), - cppu::UnoType<XGeneratedResultSet>::get()); - aOldTypes.realloc(aOldTypes.getLength() - 1); + auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(), + cppu::UnoType<XGeneratedResultSet>::get()); + aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd)); } return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits