Skip to content

Commit

Permalink
Fixed undefined behaviour: unintialized ints in for-loops (#3195)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikko Saarinki <[email protected]>
  • Loading branch information
Mikko Saarinki and Mikko Saarinki authored Nov 22, 2020
1 parent 1085e8c commit 552c9e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/common/SurgePatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 552c9e4

Please sign in to comment.