summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-18 13:29:29 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-19 10:10:23 +0100
commit6e3f0fbb95f004e125837ef2ecb216f370e59756 (patch)
treee05630f17957962337c81984846aec7b3ca5fcd9
parente867b393ef95cb9bec7f68787771dfa329b00bea (diff)
ofz: recognize invalid and negative fractions
Change-Id: Ie00a608a60a35bf333d63be54f21085ecf44347b Reviewed-on: https://gerrit.libreoffice.org/46725 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--starmath/source/mathmlattr.cxx9
1 files changed, 3 insertions, 6 deletions
diff --git a/starmath/source/mathmlattr.cxx b/starmath/source/mathmlattr.cxx
index 74e32d42944b..344c079b35e9 100644
--- a/starmath/source/mathmlattr.cxx
+++ b/starmath/source/mathmlattr.cxx
@@ -44,14 +44,11 @@ sal_Int32 ParseMathMLNumber(const OUString &rStr, Fraction& rN)
return -1;
bool bNegative = (rStr[0] == '-');
sal_Int32 nOffset = bNegative ? 1 : 0;
- Fraction aF;
- auto nIdx = ParseMathMLUnsignedNumber(rStr.copy(nOffset), aF);
- if (nIdx <= 0)
+ auto nIdx = ParseMathMLUnsignedNumber(rStr.copy(nOffset), rN);
+ if (nIdx <= 0 || !rN.IsValid())
return -1;
if (bNegative)
- rN = Fraction(aF.GetNumerator(), aF.GetDenominator());
- else
- rN = aF;
+ rN *= -1;
return nOffset + nIdx;
}