ref: d4c74b9d3bd4316a95d5803ed7dec737da94ee8d
parent: a71934dbd129bfd445c45e716a2635773473e37f
author: Ellie <64124388+ell1e@users.noreply.github.com>
date: Wed Sep 13 14:52:05 EDT 2023
Fix conditions evaluating based on uninitialized memory (#63) (benign, but might mask legitimate errors in valgrind, libasan/sanitizer, etc.)
--- a/tsf.h
+++ b/tsf.h
@@ -1729,7 +1729,7 @@
struct tsf_voice *v, *vEnd;
float pitchShift = (c->pitchWheel == 8192 ? c->tuning : ((c->pitchWheel / 16383.0f * c->pitchRange * 2.0f) - c->pitchRange + c->tuning));
for (v = f->voices, vEnd = v + f->voiceNum; v != vEnd; v++)
- if (v->playingChannel == channel && v->playingPreset != -1)
+ if (v->playingPreset != -1 && v->playingChannel == channel)
tsf_voice_calcpitchratio(v, pitchShift, f->outSampleRate);
}
@@ -1808,7 +1808,7 @@
if (!c) return 0;
if (gainDB == c->gainDB) return 1;
for (v = f->voices, vEnd = v + f->voiceNum, gainDBChange = gainDB - c->gainDB; v != vEnd; v++)
- if (v->playingChannel == channel && v->playingPreset != -1)
+ if (v->playingPreset != -1 && v->playingChannel == channel)
v->noteGainDB += gainDBChange;
c->gainDB = gainDB;
return 1;