comparison tools/xm2jss.c @ 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 cedb5ca1533b
children c0b062f881e5
comparison
equal deleted inserted replaced
1974:f9fd6b4d29f2 1975:0fddc51788de
610 dmMsg(1," * %d patterns, %d bytes.\n", 610 dmMsg(1," * %d patterns, %d bytes.\n",
611 module->npatterns, totalSize); 611 module->npatterns, totalSize);
612 612
613 // Write extended instruments 613 // Write extended instruments
614 for (totalSize = index = 0; index < module->nextInstruments; index++) 614 for (totalSize = index = 0; index < module->nextInstruments; index++)
615 if (module->extInstruments[index] != NULL)
616 { 615 {
617 JSSExtInstrument *einst = module->extInstruments[index]; 616 JSSExtInstrument *einst = module->extInstruments[index];
617 JSSExtInstrument tmpEInst;
618
619 if (einst == NULL)
620 {
621 einst = &tmpEInst;
622 memset(&tmpEInst, 0, sizeof(tmpEInst));
623 JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR,
624 "Extended instrument #%d NULL!\n",
625 index);
626 }
618 627
619 // Misc data 628 // Misc data
620 BOOL ok = 629 BOOL ok =
621 dm_fwrite_byte(outFile, einst->nsamples) && 630 dm_fwrite_byte(outFile, einst->nsamples) &&
622 dm_fwrite_byte(outFile, einst->vibratoType) && 631 dm_fwrite_byte(outFile, einst->vibratoType) &&
642 "Error writing JSSMOD extended instrument #%d.\n", 651 "Error writing JSSMOD extended instrument #%d.\n",
643 index); 652 index);
644 } 653 }
645 654
646 totalSize += sizeof(JSSMODExtInstrument); 655 totalSize += sizeof(JSSMODExtInstrument);
647 }
648 else
649 {
650 JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR,
651 "Extended instrument #%d NULL!\n",
652 index);
653 } 656 }
654 657
655 dmMsg(1," * %d Extended Instruments, %d bytes.\n", 658 dmMsg(1," * %d Extended Instruments, %d bytes.\n",
656 module->nextInstruments, totalSize); 659 module->nextInstruments, totalSize);
657 660