mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 14:20:39 +01:00
[apps/sequence][apps/graph] Reimplement checksum to avoid risking
overflowing the stack Change-Id: Ia2b70ceb174d70c20b0e7d635183a890629e4b24
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "local_context.h"
|
||||
#include "../../poincare/src/layout/string_layout.h"
|
||||
#include "../../poincare/src/layout/baseline_relative_layout.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace Shared;
|
||||
@@ -81,6 +82,16 @@ Sequence& Sequence::operator=(const Sequence& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t Sequence::checksum() {
|
||||
size_t dataLengthInBytes = 3*TextField::maxBufferSize()*sizeof(char);
|
||||
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
|
||||
char data[3*TextField::maxBufferSize()] = {};
|
||||
strlcpy(data, text(), TextField::maxBufferSize());
|
||||
strlcpy(data+TextField::maxBufferSize(), firstInitialConditionText(), TextField::maxBufferSize());
|
||||
strlcpy(data+2*TextField::maxBufferSize(), secondInitialConditionText(), TextField::maxBufferSize());
|
||||
return Ion::crc32((uint32_t *)data, dataLengthInBytes>>2);
|
||||
}
|
||||
|
||||
const char * Sequence::firstInitialConditionText() {
|
||||
return m_firstInitialConditionText;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user