ref: 3aee7f113c66f19e93f9e41a6e280e12dfd9a0e9
parent: 73da922bddede1f81fffc7e5e895cace755b378d
author: Chris Moeller <[email protected]>
date: Thu Jan 17 11:26:06 EST 2013
Fixed envelope reading to gracefully handle nodes which are out of range
--- a/dumb/src/it/readxm.c
+++ b/dumb/src/it/readxm.c
@@ -326,7 +326,7 @@
static int it_xm_make_envelope(IT_ENVELOPE *envelope, const unsigned short *data, int y_offset)
{
- int i, pos;
+ int i, pos, val;
if (envelope->n_nodes > 12) {
/* XXX
@@ -343,12 +343,13 @@
pos = 0;
for (i = 0; i < envelope->n_nodes; i++) {
envelope->node_t[i] = data[pos++];
- if (data[pos] > 64) {
- TRACE("XM error: out-of-range envelope node (node_y[%d]=%d)\n", i, data[pos]);
- envelope->n_nodes = 0;
- return -1;
+ val = data[pos++];
+ if (val > 64) {
+ TRACE("XM error: out-of-range envelope node (node_y[%d]=%d)\n", i, val);
+ /* FT2 seems to simply clip the value */
+ val = 64;
}
- envelope->node_y[i] = (signed char)(data[pos++] + y_offset);
+ envelope->node_y[i] = (signed char)(val + y_offset);
}
return 0;