# HG changeset patch # User Matti Hamalainen # Date 1578604477 -7200 # Node ID c2f0e8fbcac3ef2dfedadc48b984e7dfd48033d3 # Parent c478b35ee38837d37aff208d1270ad512382e7a7 Oops, forgot NULL checks for STIL subtunes. Should not be coding tired, deserve much spanking. diff -r c478b35ee388 -r c2f0e8fbcac3 sidinfo.c --- 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)