# HG changeset patch # User Matti Hamalainen # Date 1432204898 -10800 # Node ID dc9b20d77bc9b6256250f511839b2619fc9b62e9 # Parent 2bf7cb1e662f5ec001d04a01dd78711250938be0# Parent 94e9444b0fa72ef14d041d78d5151576716887c0 Merged. diff -r 2bf7cb1e662f -r dc9b20d77bc9 minijss/jloadxm.c --- a/minijss/jloadxm.c Thu May 21 13:41:23 2015 +0300 +++ b/minijss/jloadxm.c Thu May 21 13:41:38 2015 +0300 @@ -325,9 +325,11 @@ // Get the pattern header size and packing if (!dmf_read_le32(inFile, &xmP.headSize) || !dmf_read_byte(inFile, &xmP.packing)) + { JSSERROR(DMERR_FREAD, DMERR_FREAD, "Could not read pattern header #%d.\n", index); + } // Different format versions have slightly different headers if (module->intVersion == 0x0102) @@ -363,14 +365,18 @@ // Sanity-check rest of the header data if (xmP.packing != 0) + { JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Pattern #%d packing type unsupported (%d)\n", index, xmP.packing); + } if (xmP.nrows == 0) + { JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Pattern #%d has %d rows, invalid data.\n", index, xmP.nrows); + } if (xmP.size > 0) { @@ -580,9 +586,11 @@ inst->loopS = xmS.loopS / sizeof(Uint16); inst->loopE = (xmS.loopS + xmS.loopL) / sizeof(Uint16); if ((xmS.size & 1) || (xmS.loopS & 1) || (xmS.loopL & 1)) + { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, "Samp #%d/%d: size=%d, loopS=%d or loopL=%d not divisible by 2 for 16-bit sample.\n", neinst, nsample, xmS.size, xmS.loopS, xmS.loopL); + } } else { @@ -735,7 +743,8 @@ !dmf_read_le16(inFile, &xmI1.nsamples)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Failed to read primary extended instrument header #%d\n", neinst); + "Failed to read primary extended instrument header #%d.\n", + neinst); } // If there are samples, there is header #2 @@ -756,9 +765,11 @@ neinst, module->nextInstruments); if ((einst = jssAllocateExtInstrument()) == NULL) + { JSSERROR(DMERR_MALLOC, DMERR_MALLOC, "Could not allocate extended instrument #%d.\n", neinst); + } module->extInstruments[neinst] = einst; @@ -767,14 +778,16 @@ !dmf_read_str(inFile, &xmI2.sNumForNotes, sizeof(xmI2.sNumForNotes))) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read secondary instrument header part #1 for #%d.\n", neinst); + "Could not read secondary instrument header part #1 for #%d.\n", + neinst); } if (!jssXMLoadEnvelopePoints(inFile, &xmI2.volumeEnv) || !jssXMLoadEnvelopePoints(inFile, &xmI2.panningEnv)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read envelope point data for instrument #%d.\n", neinst); + "Could not read envelope point data for instrument #%d.\n", + neinst); } if (!dmf_read_byte(inFile, &xmI2.volumeEnv.npoints) || @@ -795,7 +808,8 @@ !dmf_read_le16(inFile, &xmI2.ARESERVED)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read secondary instrument header part #2 for #%d.\n", neinst); + "Could not read secondary instrument header part #2 for #%d.\n", + neinst); } // Skip the extra data after header #2 @@ -1040,7 +1054,7 @@ module->defFlags |= jmdfAmigaPeriods; // Setup the default pannings - for (index = 0; index < jsetNChannels; index++) + for (index = 0; index < module->nchannels; index++) module->defPanning[index] = jchPanMiddle; // Load rest of the module