mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 16:57:31 +01:00
[apps/sequence][apps/graph] Reimplement checksum to avoid risking
overflowing the stack Change-Id: Ia2b70ceb174d70c20b0e7d635183a890629e4b24
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "function.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
@@ -25,6 +26,14 @@ Function& Function::operator=(const Function& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t Function::checksum() {
|
||||
size_t dataLengthInBytes = TextField::maxBufferSize()*sizeof(char);
|
||||
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
|
||||
char data[TextField::maxBufferSize()] = {};
|
||||
strlcpy(data, m_text, TextField::maxBufferSize());
|
||||
return Ion::crc32((uint32_t *)data, dataLengthInBytes>>2);
|
||||
}
|
||||
|
||||
void Function::setContent(const char * c) {
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
if (m_layout != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user