fix broken error path
[picodrive.git] / pico / cart.c
index 377ecbc..d091d62 100644 (file)
@@ -8,9 +8,9 @@
  */\r
 \r
 #include "pico_int.h"\r
-#include "../zlib/zlib.h"\r
 #include "../cpu/debug.h"\r
 #include "../unzip/unzip.h"\r
+#include <zlib.h>\r
 \r
 \r
 static int rom_alloc_size;\r
@@ -569,7 +569,7 @@ int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms)
     bytes_read = pm_read(rom,size,f); // Load up the rom\r
   if (bytes_read <= 0) {\r
     elprintf(EL_STATUS, "read failed");\r
-    free(rom);\r
+    plat_munmap(rom, rom_alloc_size);\r
     return 3;\r
   }\r
 \r