changeset 8:cfc74ec918dc

Fix handling of "large" SID files.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 25 Sep 2014 02:07:38 +0300
parents 36c43f085b28
children c1fba4abf56f
files sidinfo.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sidinfo.c	Thu Sep 25 02:07:21 2014 +0300
+++ b/sidinfo.c	Thu Sep 25 02:07:38 2014 +0300
@@ -351,19 +351,21 @@
     {
         read = fread(fileData, sizeof(uint8_t), PSID_BUFFER_SIZE, inFile);
         psid->dataSize += read;
-        if (read < 16)
-        {
-            THERR("Error reading song data, unexpectedly small file.\n");
-            goto error;
-        }
 
         if (first && psid->loadAddress == 0)
         {
+            if (read < 4)
+            {
+                THERR("Error reading song data, unexpectedly small file.\n");
+                goto error;
+            }
+
             // Strip load address (2 first bytes)
             th_md5_append(&state, &fileData[2], read - 2);
             first = FALSE;
         }
         else
+        if (read > 0)
         {
             // Append "as is"
             th_md5_append(&state, fileData, read);