Kaydet (Commit) 1ca93889 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#4976 Integer-overflow

Change-Id: Iefba0ea6122bd9b1dde59f33c0c67077fecb7eca
üst 6484dcf4
......@@ -63,6 +63,7 @@
#include "lwpobjid.hxx"
#include "lwptools.hxx"
#include <o3tl/safeint.hxx>
#include <memory>
class LwpObjectStream;
......@@ -434,11 +435,17 @@ private:
inline double LwpIndentOverride::GetFirst() const
{
return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nFirst-m_nRest));
sal_Int32 nRes;
if (o3tl::checked_sub(m_nFirst, m_nRest, nRes))
throw std::range_error("bad len");
return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(nRes));
}
inline double LwpIndentOverride::GetLeft() const
{
return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(m_nAll+m_nRest));
sal_Int32 nRes;
if (o3tl::checked_add(m_nAll, m_nRest, nRes))
throw std::range_error("bad len");
return LwpTools::ConvertToMetric(LwpTools::ConvertFromUnits(nRes));
}
inline double LwpIndentOverride::GetRight() const
{
......
......@@ -457,7 +457,7 @@ void LwpParaStyle::ApplyIndent(LwpPara* pPara, XFParaStyle* pParaStyle, LwpInden
else if (relative == LwpIndentOverride::RELATIVE_REST)
Amount += pParentIndent->GetMRest();
pTotalIndent->SetMAll(o3tl::saturating_add(Amount, pTotalIndent->GetMAll()));
pTotalIndent->SetMRight(pParentIndent->GetMRight()+ pTotalIndent->GetMRight());
pTotalIndent->SetMRight(o3tl::saturating_add(pParentIndent->GetMRight(), pTotalIndent->GetMRight()));
pParaStyle->SetIndent(pTotalIndent->GetFirst());
pParaStyle->SetMargins(pTotalIndent->GetLeft(), pTotalIndent->GetRight());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment