diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-04-10 20:35:50 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-04-11 12:06:51 +0200 |
commit | ed901cc95b24d01c741861526d66f9451827c0ba (patch) | |
tree | 93cb29323b9ecbc5241e4a3e589595d4b8744e6e /hwpfilter | |
parent | 20ceadb1cf73c27011a32a243726ac11f3839ace (diff) |
Related: ofz#31685 Timeout. This hunk is a simple swap
Change-Id: Ia4c0f2727c0278496c68f54eca3046a924fa21e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113930
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/hwpread.cxx | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx index 36fb77996c56..ca2a2eff534e 100644 --- a/hwpfilter/source/hwpread.cxx +++ b/hwpfilter/source/hwpread.cxx @@ -285,7 +285,7 @@ bool TxtBox::Read(HWPFile & hwpf) ncell = nCell; if (ncell <= 0){ return hwpf.SetState(HWP_InvalidFileFormat); - } + } cell.reset( ::comphelper::newArray_null<Cell>(ncell) ); if (!cell) { @@ -333,22 +333,18 @@ bool TxtBox::Read(HWPFile & hwpf) tcell->pCell = &cell[ii]; pArr[ii] = tcell; } - TCell *tmp; + // Sort by row and column for( ii = 0 ; ii < ncell - 1; ii++ ){ for( int jj = ii ; jj < ncell ; jj++){ if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){ - tmp = pArr[ii]; - pArr[ii] = pArr[jj]; - pArr[jj] = tmp; + std::swap(pArr[ii], pArr[jj]); } } for( int kk = ii ; kk > 0 ; kk--){ if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) && (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){ - tmp = pArr[kk]; - pArr[kk] = pArr[kk-1]; - pArr[kk-1] = tmp; + std::swap(pArr[kk], pArr[kk-1]); } } } |