From b96dbb237778d531aaf46485e9c9e55338998f66 Mon Sep 17 00:00:00 2001 From: Purdea Andrei Date: Mon, 16 Jan 2023 10:30:37 +0200 Subject: [PATCH] =?UTF-8?q?Miniware+Pinecil:=20fix=20number=20of=20items?= =?UTF-8?q?=20in=20uVtoDegC=20array.=20This=20only=20af=E2=80=A6=20(#1531)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Miniware+Pinecil: fix number of items in uVtoDegC array. This only affects us in case we go above 500degC, in which case we'll be reading invalid memory --- source/Core/BSP/Miniware/ThermoModel.cpp | 2 +- source/Core/BSP/Pinecil/ThermoModel.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Core/BSP/Miniware/ThermoModel.cpp b/source/Core/BSP/Miniware/ThermoModel.cpp index 1b04bd5f7f..25376d4ed2 100644 --- a/source/Core/BSP/Miniware/ThermoModel.cpp +++ b/source/Core/BSP/Miniware/ThermoModel.cpp @@ -125,6 +125,6 @@ const int32_t uVtoDegC[] = { 38137, 500, // }; #endif -const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t)); +const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uVtoDegC[0])); uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta); } diff --git a/source/Core/BSP/Pinecil/ThermoModel.cpp b/source/Core/BSP/Pinecil/ThermoModel.cpp index 846a0a009e..fa2cd65d34 100644 --- a/source/Core/BSP/Pinecil/ThermoModel.cpp +++ b/source/Core/BSP/Pinecil/ThermoModel.cpp @@ -67,6 +67,6 @@ const int32_t uVtoDegC[] = { }; #endif -const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t)); +const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uVtoDegC[0])); uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta); }