Browse code

Fix potential out of bounds when doing tuning lookup

Bad Diode authored on 23/10/2023 09:10:03 • neauoire committed on 03/11/2023 00:30:14
Showing 1 changed files
... ...
@@ -132,9 +132,6 @@ note_on(AudioChannel *channel, float duration, Uint8 *data, Uint16 len, Uint8 vo
132 132
 		sample.loop = 0;
133 133
 	}
134 134
 	env_on(&sample.env);
135
-	if(pitch < 20) {
136
-		pitch = 20;
137
-	}
138 135
 	float sample_rate = 44100 / 261.60;
139 136
 	if(len <= 256) {
140 137
 		sample_rate = len;
... ...
@@ -305,6 +302,9 @@ audio_start(int idx, Uint8 *d, Uxn *u)
305 302
 	Uint8 off = d[0xf] == 0x00;
306 303
 	Uint16 len = PEEK2(d + 0xa);
307 304
 	Uint8 pitch = d[0xf] & 0x7f;
305
+	if(pitch < 20) {
306
+		pitch = 20;
307
+	}
308 308
 	float duration = dur > 0 ? dur : calc_duration(len, pitch);
309 309
 
310 310
 	if(!off) {