summaryrefslogtreecommitdiffstats
path: root/hwpfilter/source/hwpread.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-28 12:52:01 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-28 12:55:02 +0100
commit032e7a4b5c4904d00b3f0ab75af113ed316343f8 (patch)
treedba6395de1007a0e092ce050745cae1ef7964f8b /hwpfilter/source/hwpread.cxx
parentconvert to std::vector (diff)
downloadcore-032e7a4b5c4904d00b3f0ab75af113ed316343f8.tar.gz
core-032e7a4b5c4904d00b3f0ab75af113ed316343f8.zip
ofz: avoid timeout and return early on failure
Change-Id: I083aa07b311fa073ea5eeb1d569b0902e0f9c095
Diffstat (limited to 'hwpfilter/source/hwpread.cxx')
-rw-r--r--hwpfilter/source/hwpread.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 1a96eaa29046..92f484b1d10d 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -185,7 +185,7 @@ static void UpdateBBox(FBox * fbox)
fbox->boundey = fbox->pgy + fbox->ys - 1;
}
-void Cell::Read(HWPFile & hwpf)
+bool Cell::Read(HWPFile & hwpf)
{
hwpf.Read2b(&p, 1);
hwpf.Read2b(&color, 1);
@@ -203,7 +203,7 @@ void Cell::Read(HWPFile & hwpf)
hwpf.Read1b(linetype, 4);
hwpf.Read1b(&shade, 1);
hwpf.Read1b(&diagonal, 1);
- hwpf.Read1b(&protect, 1);
+ return hwpf.Read1b(&protect, 1) == 1;
}
bool TxtBox::Read(HWPFile & hwpf)
@@ -288,11 +288,14 @@ bool TxtBox::Read(HWPFile & hwpf)
if (!cell) {
return hwpf.SetState(HWP_InvalidFileFormat);
}
- for (ii = 0; ii < ncell; ii++)
+ bool bSuccess = true;
+ for (ii = 0; ii < ncell && bSuccess; ii++)
{
- cell[ii].Read(hwpf);
+ bSuccess = cell[ii].Read(hwpf);
cell[ii].key = sal::static_int_cast<unsigned char>(ii);
}
+ if (!bSuccess)
+ return false;
if (ncell == 1)
style.cell = &cell[0];
plists.resize(ncell);