diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-28 12:52:01 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-28 12:55:02 +0100 |
commit | 032e7a4b5c4904d00b3f0ab75af113ed316343f8 (patch) | |
tree | dba6395de1007a0e092ce050745cae1ef7964f8b | |
parent | 6394fd4a1d56af4afab4f9683d5a2087a32588e6 (diff) |
ofz: avoid timeout and return early on failure
Change-Id: I083aa07b311fa073ea5eeb1d569b0902e0f9c095
-rw-r--r-- | hwpfilter/source/hbox.h | 2 | ||||
-rw-r--r-- | hwpfilter/source/hwpread.cxx | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h index 5ed353364c0f..a110d70d0f32 100644 --- a/hwpfilter/source/hbox.h +++ b/hwpfilter/source/hbox.h @@ -228,7 +228,7 @@ struct Cell // Cell unsigned char diagonal; // { 0=none,\=1,/=2,X=3} unsigned char protect; - void Read( HWPFile &hwpf ); + bool Read(HWPFile &hwpf); }; /** 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); |