- Update DUMB to revision 3aee7f113c66f19e93f9e41a6e280e12dfd9a0e9

- Fixed envelope reading to gracefully handle nodes which are out of range



SVN r4116 (trunk)
This commit is contained in:
Randy Heit 2013-02-08 01:34:05 +00:00
parent cfaecc12a3
commit 3c50b1c14b

View file

@ -338,7 +338,7 @@ static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels,
static int it_xm_make_envelope(IT_ENVELOPE *envelope, const unsigned short *data, int y_offset) 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) { if (envelope->n_nodes > 12) {
/* XXX /* XXX
@ -355,12 +355,13 @@ static int it_xm_make_envelope(IT_ENVELOPE *envelope, const unsigned short *data
pos = 0; pos = 0;
for (i = 0; i < envelope->n_nodes; i++) { for (i = 0; i < envelope->n_nodes; i++) {
envelope->node_t[i] = data[pos++]; envelope->node_t[i] = data[pos++];
if (data[pos] > 64) { val = data[pos++];
TRACE("XM error: out-of-range envelope node (node_y[%d]=%d)\n", i, data[pos]); if (val > 64) {
envelope->n_nodes = 0; TRACE("XM error: out-of-range envelope node (node_y[%d]=%d)\n", i, val);
return -1; /* 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; return 0;