vcl/osx/a11ytablewrapper.mm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
New commits: commit d96c98647511b6c1f1d1d9a969df39f859cc0696 Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Mon Jan 9 18:00:11 2023 -0500 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 10 06:53:53 2023 +0000 tdf#152648 Handle overflow when multiplying rows and columns Change-Id: I1f3b4853fb6e6a66e74e798d6594342c84d5a695 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145245 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/osx/a11ytablewrapper.mm b/vcl/osx/a11ytablewrapper.mm index 0cd98c7863dd..6f8775f0a4b5 100644 --- a/vcl/osx/a11ytablewrapper.mm +++ b/vcl/osx/a11ytablewrapper.mm @@ -39,8 +39,10 @@ using namespace ::com::sun::star::uno; { sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); - - if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + + // tdf#152648 Handle overflow when multiplying rows and columns + sal_Int64 nCells = static_cast<sal_Int64>(nRows) * static_cast<sal_Int64>(nCols); + if( nCells >= 0 && nCells < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { // make all children visible to the hierarchy for ( sal_Int32 rowCount = 0; rowCount < nRows; rowCount++ ) @@ -111,9 +113,10 @@ using namespace ::com::sun::star::uno; { sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); - - - if( nRows*nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + + // tdf#152648 Handle overflow when multiplying rows and columns + sal_Int64 nCells = static_cast<sal_Int64>(nRows) * static_cast<sal_Int64>(nCols); + if( nCells >= 0 && nCells < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { [ attributeNames addObject: NSAccessibilityRowsAttribute ]; [ attributeNames addObject: NSAccessibilityColumnsAttribute ]; @@ -130,7 +133,10 @@ using namespace ::com::sun::star::uno; { sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); - if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + + // tdf#152648 Handle overflow when multiplying rows and columns + sal_Int64 nCells = static_cast<sal_Int64>(nRows) * static_cast<sal_Int64>(nCols); + if( nCells >= 0 && nCells < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; try @@ -168,7 +174,10 @@ using namespace ::com::sun::star::uno; { sal_Int32 nRows = accessibleTable->getAccessibleRowCount(); sal_Int32 nCols = accessibleTable->getAccessibleColumnCount(); - if( nRows * nCols < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) + + // tdf#152648 Handle overflow when multiplying rows and columns + sal_Int64 nCells = static_cast<sal_Int64>(nRows) * static_cast<sal_Int64>(nCols); + if( nCells >= 0 && nCells < MAXIMUM_ACCESSIBLE_TABLE_CELLS ) { NSMutableArray * cells = [ [ NSMutableArray alloc ] init ]; try