cd: fix missed null terminator
[picodrive.git] / pico / cd / cd_image.c
index 97c8f3f..ae2ef0c 100644 (file)
@@ -61,6 +61,7 @@ static void to_upper(char *d, const char *s)
     else
       *d = *s;
   }
+  *d = 0;
 }
 
 // cdd.c uses lba - 150
@@ -183,7 +184,6 @@ int load_cd_image(const char *cd_img_name, int *type)
       elprintf(EL_STATUS, "Track %2i: %s %9i AUDIO %s",
         n, tmp_ext, length, cue_data->tracks[n].fname);
     }
-    cue_destroy(cue_data);
     goto finish;
   }
 
@@ -260,6 +260,9 @@ finish:
   if (PicoCDLoadProgressCB != NULL)
     PicoCDLoadProgressCB(cd_img_name, 100);
 
+  if (cue_data != NULL)
+    cue_destroy(cue_data);
+
   return 0;
 }