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.grandin@collabora.co.uk>
(cherry picked from commit d96c98647511b6c1f1d1d9a969df39f859cc0696)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145228
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/vcl/osx/a11ytablewrapper.mm b/vcl/osx/a11ytablewrapper.mm
index 0cd98c7..6f8775f 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