From 7f0dc24f8dcdcf782fb50d7ca84756b2f8b00a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 14 Aug 2018 18:20:12 +0200 Subject: [PATCH] [poincare] Integer: add safeguards on infinite Integer --- poincare/src/integer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/poincare/src/integer.cpp b/poincare/src/integer.cpp index 7b061e6cb..bc6946ef5 100644 --- a/poincare/src/integer.cpp +++ b/poincare/src/integer.cpp @@ -105,6 +105,10 @@ T NaturalIntegerAbstract::approximate() const { * - the mantissa is the beginning of our BigInt, discarding the first bit */ + if (isInfinity()) { + return INFINITY; + } + native_uint_t lastDigit = digit(m_numberOfDigits-1); uint8_t numberOfBitsInLastDigit = log2(lastDigit); @@ -155,6 +159,7 @@ T NaturalIntegerAbstract::approximate() const { // Properties int NaturalIntegerAbstract::NumberOfBase10Digits(const NaturalIntegerAbstract * i) { + assert(!i->isInfinity()); int numberOfDigits = 1; Integer ref(i); Integer base(10);