From 552c9e4ec8915557a8b9b02da20086baf29b6132 Mon Sep 17 00:00:00 2001 From: Mikko Saarinki Date: Sun, 22 Nov 2020 14:50:25 +0200 Subject: [PATCH] Fixed undefined behaviour: unintialized ints in for-loops (#3195) Co-authored-by: Mikko Saarinki --- src/common/SurgePatch.cpp | 4 ++-- src/common/gui/SurgeGUIEditor.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/SurgePatch.cpp b/src/common/SurgePatch.cpp index 6430887763d..7a434f0ff06 100644 --- a/src/common/SurgePatch.cpp +++ b/src/common/SurgePatch.cpp @@ -1319,7 +1319,7 @@ void SurgePatch::load_xml(const void* data, int datasize, bool is_preset) if (scene[0].pbrange_up.val.i & 0xffffff00) // is outside range, it must have been save { - for (int sc; sc < n_scenes; sc++) + for (int sc = 0; sc < n_scenes; sc++) { scene[sc].pbrange_up.val.i = (int)scene[sc].pbrange_up.val.f; scene[sc].pbrange_dn.val.i = (int)scene[sc].pbrange_dn.val.f; @@ -1328,7 +1328,7 @@ void SurgePatch::load_xml(const void* data, int datasize, bool is_preset) if (revision < 1) { - for (int sc; sc < n_scenes; sc++) + for (int sc = 0; sc < n_scenes; sc++) { scene[sc].adsr[0].a_s.val.i = limit_range(scene[sc].adsr[0].a_s.val.i + 1, 0, 2); scene[sc].adsr[1].a_s.val.i = limit_range(scene[sc].adsr[1].a_s.val.i + 1, 0, 2); diff --git a/src/common/gui/SurgeGUIEditor.cpp b/src/common/gui/SurgeGUIEditor.cpp index a7df3e18444..d12dee4de54 100644 --- a/src/common/gui/SurgeGUIEditor.cpp +++ b/src/common/gui/SurgeGUIEditor.cpp @@ -3004,7 +3004,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b { contextMenu->addSeparator(eid++); - for (int i; i < lt_num_deforms[lfodata->shape.val.i]; i++) + for (int i = 0; i < lt_num_deforms[lfodata->shape.val.i]; i++) { char title[32]; sprintf(title, "Deform Type %d", (i + 1));