changeset 1975:0fddc51788de

Fix writing of JSSMOD for NULL extended instruments.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Jul 2018 02:34:52 +0300
parents f9fd6b4d29f2
children 5f9e8dd62c70
files tools/xm2jss.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/tools/xm2jss.c	Sun Jul 01 00:15:38 2018 +0300
+++ b/tools/xm2jss.c	Sun Jul 01 02:34:52 2018 +0300
@@ -612,9 +612,18 @@
 
     // Write extended instruments
     for (totalSize = index = 0; index < module->nextInstruments; index++)
-    if (module->extInstruments[index] != NULL)
     {
         JSSExtInstrument *einst = module->extInstruments[index];
+        JSSExtInstrument tmpEInst;
+
+        if (einst == NULL)
+        {
+            einst = &tmpEInst;
+            memset(&tmpEInst, 0, sizeof(tmpEInst));
+            JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR,
+            "Extended instrument #%d NULL!\n",
+            index);
+        }
 
         // Misc data
         BOOL ok =
@@ -645,12 +654,6 @@
 
         totalSize += sizeof(JSSMODExtInstrument);
     }
-    else
-    {
-        JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR,
-        "Extended instrument #%d NULL!\n",
-        index);
-    }
 
     dmMsg(1," * %d Extended Instruments, %d bytes.\n",
         module->nextInstruments, totalSize);