changeset 303:c2f0e8fbcac3

Oops, forgot NULL checks for STIL subtunes. Should not be coding tired, deserve much spanking.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 23:14:37 +0200
parents c478b35ee388
children 9a5f87c664e6
files sidinfo.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sidinfo.c	Thu Jan 09 22:46:10 2020 +0200
+++ b/sidinfo.c	Thu Jan 09 23:14:37 2020 +0200
@@ -1179,21 +1179,23 @@
                 // We need to count the number of fields to be outputted
                 // beforehand, so we can know when we are at the last one
                 for (int nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
+                if (psid->stil->subtunes[nsubtune] != NULL)
                 {
-                    SIDLibSTILSubTune *node = psid->stil->subtunes[nsubtune];
+                    SIDLibSTILSubTune *subtune = psid->stil->subtunes[nsubtune];
                     for (int nfield = 0; nfield < STF_LAST; nfield++)
-                        nfieldcount += node->fields[nfield].ndata;
+                        nfieldcount += subtune->fields[nfield].ndata;
                 }
 
                 for (int nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
+                if (psid->stil->subtunes[nsubtune] != NULL)
                 {
-                    SIDLibSTILSubTune *node = psid->stil->subtunes[nsubtune];
+                    SIDLibSTILSubTune *subtune = psid->stil->subtunes[nsubtune];
                     int maxdata = 0;
 
                     // For each subtune we need to check the max number of field data items
                     for (int nfield = 0; nfield < STF_LAST; nfield++)
                     {
-                        SIDLibSTILField *fld = &node->fields[nfield];
+                        SIDLibSTILField *fld = &subtune->fields[nfield];
                         if (fld->ndata > maxdata)
                             maxdata = fld->ndata;
                     }
@@ -1202,7 +1204,7 @@
                     for (int nitem = 0; nitem < maxdata; nitem++)
                     for (int nfield = 0; nfield < STF_LAST; nfield++)
                     {
-                        SIDLibSTILField *fld = &node->fields[nfield];
+                        SIDLibSTILField *fld = &subtune->fields[nfield];
                         if (nitem < fld->ndata)
                         {
                             if (nsubtune > 0)