changeset 1311:f1c4b9b074ad

Fixes to jssmod loader.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 20 Aug 2017 01:01:40 +0300
parents dce4730372c7
children 4eb394c9e682
files minijss/jloadjss.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/minijss/jloadjss.c	Sun Aug 20 01:01:12 2017 +0300
+++ b/minijss/jloadjss.c	Sun Aug 20 01:01:40 2017 +0300
@@ -414,6 +414,7 @@
             "Invalid orders list entry #%d value %d > %d.\n",
             index, tmp, jssH.npatterns);
 
+        module->orderList[index] = (tmp == 0xffff) ? jsetNotSet : tmp;
     }
 
     // Parse the patterns
@@ -509,14 +510,13 @@
         }
         
         // Allocate instrument
-        if ((einst = jssAllocateExtInstrument()) == NULL)
+        einst = module->extInstruments[index] = jssAllocateExtInstrument();
+        if (einst == NULL)
         {
             JSSERROR(DMERR_MALLOC, DMERR_MALLOC,
             "Could not allocate extended instrument structure #%d\n", index);
         }
 
-        module->extInstruments[index] = einst;
-
         einst->nsamples     = jssE.nsamples;
         einst->vibratoType  = jssE.vibratoType;
         einst->vibratoSweep = jssE.vibratoSweep;
@@ -580,7 +580,7 @@
         // Validate what we can
         if (jssI.loopS > jssI.size ||
             jssI.loopE > jssI.size ||
-            jssI.loopE > jssI.loopS)
+            jssI.loopS > jssI.loopE)
         {
             JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
             "Invalid or corrupted sample instrument #%d.\n",
@@ -588,6 +588,13 @@
         }
 
         // Allocate instrument
+        inst = module->instruments[index] = jssAllocateInstrument();
+        if (inst == NULL)
+        {
+            JSSERROR(DMERR_MALLOC, DMERR_MALLOC,
+            "Could not allocate sample instrument structure #%d\n",
+            index);
+        }
 
         // Copy data
         inst->size          = jssI.size;