Schwabe/fix curve overflow (#4951)
* Fix curve editing function not checking if there is space for the curve * Fix compile error
This commit is contained in:
committed by
Bertrand Songis
parent
c79994d812
commit
4880c029b7
+16
-1
@@ -26,6 +26,7 @@ uint8_t s_curveChan;
|
||||
int8_t * curveEnd[MAX_CURVES];
|
||||
void loadCurves()
|
||||
{
|
||||
bool showWarning= false;
|
||||
int8_t * tmp = g_model.points;
|
||||
for (int i=0; i<MAX_CURVES; i++) {
|
||||
switch (g_model.curves[i].type) {
|
||||
@@ -41,7 +42,21 @@ void loadCurves()
|
||||
tmp += 5+g_model.curves[i].points;
|
||||
break;
|
||||
}
|
||||
// Older version did not check if we exceeded the array
|
||||
int8_t * maxend = &g_model.points[MAX_CURVE_POINTS - 2*(MAX_CURVES-i-1)];
|
||||
if (tmp > maxend) {
|
||||
tmp = maxend;
|
||||
g_model.curves[i].type=CURVE_TYPE_STANDARD;
|
||||
g_model.curves[i].points=-3;
|
||||
showWarning=true;
|
||||
}
|
||||
curveEnd[i] = tmp;
|
||||
|
||||
}
|
||||
if (showWarning) {
|
||||
POPUP_WARNING("Invalid curve data repaired");
|
||||
const char * w = "check your curves, logic switches";
|
||||
SET_WARNING_INFO(w, strlen(w), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +65,7 @@ int8_t * curveAddress(uint8_t idx)
|
||||
return idx==0 ? g_model.points : curveEnd[idx-1];
|
||||
}
|
||||
|
||||
bool moveCurve(uint8_t index, int8_t shift) // TODO bool?
|
||||
bool moveCurve(uint8_t index, int8_t shift)
|
||||
{
|
||||
if (curveEnd[MAX_CURVES-1] + shift > g_model.points + sizeof(g_model.points)) {
|
||||
AUDIO_WARNING2();
|
||||
|
||||
Reference in New Issue
Block a user