diff serialize.c @ 1428:2540c05520f2

New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
author Michael Pavone <pavone@retrodev.com>
date Wed, 09 Aug 2017 23:26:51 -0700
parents 4e5797b3935a
children c3c62dbf1ceb
line wrap: on
line diff
--- a/serialize.c	Sun Aug 06 00:06:36 2017 -0700
+++ b/serialize.c	Wed Aug 09 23:26:51 2017 -0700
@@ -257,7 +257,6 @@
 		fclose(f);
 		return 0;
 	}
-	fclose(f);
 	if (memcmp(ident, sz_ident, sizeof(ident))) {
 		return 0;
 	}
@@ -267,10 +266,12 @@
 	buf->handlers = NULL;
 	buf->max_handler = 8;
 	if (fread(buf->data, 1, buf->size, f) != buf->size) {
+		fclose(f);
 		free(buf->data);
 		buf->data = NULL;
 		buf->size = 0;
 		return 0;
 	}
+	fclose(f);
 	return 1;
 }