From 7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b Mon Sep 17 00:00:00 2001 From: Michael Stummvoll Date: Thu, 25 Nov 2010 12:45:13 +0000 Subject: Added the snapshot patch for rockboy (FS#11757) Added a simple filesize-check for the options file before loading to avoid crashes due the changed config git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28664 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/rockboy/rockboy.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'apps/plugins/rockboy/rockboy.c') diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 0364f47faa..5464a2a416 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c @@ -71,8 +71,17 @@ static void setoptions (void) snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); fd = open(optionsave, O_RDONLY); - if(fd < 0) /* no options to read, set defaults */ + + int optionssize = sizeof(options); + int filesize = 0; + if(fd >= 0) + filesize = rb->filesize(fd); + + /* don't read the option file if the size + * is not as expected to avoid crash */ + if(fd < 0 || filesize!=optionssize) { + // no options to read, set defaults #ifdef HAVE_TOUCHSCREEN options.LEFT = BUTTON_MIDLEFT; options.RIGHT = BUTTON_MIDRIGHT; @@ -378,6 +387,7 @@ static int gnuboy_main(const char *rom) rb->lcd_puts(0,4,"Emu run"); rb->lcd_clear_display(); rb->lcd_update(); + if(options.autosave) sn_load(); emu_run(); /* never reached */ -- cgit v1.2.3