shithub: dumb

Download patch

ref: f88ffd1cf197aa2c0fe407165d5c668aa335d2e2
parent: a54a640f5a2aa4dfc24947e6ec7fc652bba65f2d
author: Christopher Snowhill <kode54@gmail.com>
date: Sun Oct 8 14:14:23 EDT 2017

Last minute fix for weird pattern reading issues, so less bad patterns hit the renderer.

--- a/src/it/itorder.c
+++ b/src/it/itorder.c
@@ -40,6 +40,10 @@
             sigdata->order[i] <= last_invalid) {
             sigdata->order[i] = sigdata->n_patterns;
             found_some = 1;
+        } else if (sigdata->order[i] < first_invalid) {
+            IT_PATTERN *pattern = sigdata->pattern + sigdata->order[i];
+            if (!pattern->n_rows || (pattern->n_entries && !pattern->entry))
+                return -1;
         }
     }
 
--- a/src/it/itread.c
+++ b/src/it/itread.c
@@ -1438,7 +1438,10 @@
     free(buffer);
     free(component);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/read669.c
+++ b/src/it/read669.c
@@ -423,7 +423,10 @@
         sigdata->channel_pan[i + 1] = 32 - sep;
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readam.c
+++ b/src/it/readam.c
@@ -463,7 +463,10 @@
         }
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 
--- a/src/it/readamf.c
+++ b/src/it/readamf.c
@@ -536,8 +536,6 @@
     sigdata->mixing_volume = 48;
     sigdata->pan_separation = 128;
 
-    _dumb_it_fix_invalid_orders(sigdata);
-
     for (i = 0; i < realntracks; i++) {
         if (track[i]) {
             free(track[i]);
@@ -546,6 +544,11 @@
     free(track);
     free(trackmap);
     free(orderstotracks);
+
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 
--- a/src/it/readasy.c
+++ b/src/it/readasy.c
@@ -314,7 +314,10 @@
         sigdata->channel_pan[i + 3] = 32 - sep;
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readdsmf.c
+++ b/src/it/readdsmf.c
@@ -357,7 +357,10 @@
         }
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 
--- a/src/it/readmod.c
+++ b/src/it/readmod.c
@@ -621,7 +621,10 @@
         sigdata->channel_pan[i + 3] = 32 - sep;
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readmtm.c
+++ b/src/it/readmtm.c
@@ -389,11 +389,14 @@
             goto error_fs;
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
-
     free(sequence);
     free(track);
     free(skip_bytes);
+
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 
--- a/src/it/readokt.c
+++ b/src/it/readokt.c
@@ -577,7 +577,10 @@
     memset(sigdata->channel_pan + n_channels, 32,
            DUMB_IT_N_CHANNELS - n_channels);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readoldpsm.c
+++ b/src/it/readoldpsm.c
@@ -705,7 +705,8 @@
         }
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0)
+        goto error_fc;
 
     free(component);
 
--- a/src/it/readpsm.c
+++ b/src/it/readpsm.c
@@ -1062,7 +1062,10 @@
     free(songchunk);
     free_chunks(chunk, n_chunks);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     dumb_it_optimize_orders(sigdata);
 
--- a/src/it/readptm.c
+++ b/src/it/readptm.c
@@ -535,7 +535,10 @@
     free(buffer);
     free(component);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/reads3m.c
+++ b/src/it/reads3m.c
@@ -734,7 +734,10 @@
     free(buffer);
     free(component);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readstm.c
+++ b/src/it/readstm.c
@@ -355,7 +355,10 @@
         }
     }
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }
--- a/src/it/readxm.c
+++ b/src/it/readxm.c
@@ -1252,7 +1252,10 @@
     memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
     memset(sigdata->channel_pan, 32, DUMB_IT_N_CHANNELS);
 
-    _dumb_it_fix_invalid_orders(sigdata);
+    if (_dumb_it_fix_invalid_orders(sigdata) < 0) {
+        _dumb_it_unload_sigdata(sigdata);
+        return NULL;
+    }
 
     return sigdata;
 }