From 01e67dbdc07d9877de4bfd5ec32e044b1ff4bc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 19 Nov 2018 17:30:22 +0100 Subject: [PATCH] [apps/probability] Fix law parameters display in calculation step --- apps/probability/calculation_controller.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/probability/calculation_controller.cpp b/apps/probability/calculation_controller.cpp index 831c35283..ea4311966 100644 --- a/apps/probability/calculation_controller.cpp +++ b/apps/probability/calculation_controller.cpp @@ -273,14 +273,23 @@ TextFieldDelegateApp * CalculationController::textFieldDelegateApp() { void CalculationController::updateTitle() { int currentChar = 0; for (int index = 0; index < m_law->numberOfParameter(); index++) { + if (currentChar >= k_maxNumberOfTitleCharacters) { + break; + } m_titleBuffer[currentChar++] = I18n::translate(m_law->parameterNameAtIndex(index))[0]; - strlcpy(m_titleBuffer+currentChar, " = ", k_maxNumberOfTitleCharacters); + strlcpy(m_titleBuffer+currentChar, " = ", k_maxNumberOfTitleCharacters - currentChar); currentChar += 3; + if (currentChar >= k_maxNumberOfTitleCharacters) { + break; + } const size_t bufferSize = PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits); char buffer[bufferSize]; PrintFloat::convertFloatToText(m_law->parameterValueAtIndex(index), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits), Constant::ShortNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal); - strlcpy(m_titleBuffer+currentChar, buffer, bufferSize - currentChar); + strlcpy(m_titleBuffer+currentChar, buffer, k_maxNumberOfTitleCharacters - currentChar); currentChar += strlen(buffer); + if (currentChar >= k_maxNumberOfTitleCharacters) { + break; + } m_titleBuffer[currentChar++] = ' '; } m_titleBuffer[currentChar-1] = 0;