diff options
author | Michael Stummvoll <michael@stummi.org> | 2010-11-25 12:45:13 +0000 |
---|---|---|
committer | Michael Stummvoll <michael@stummi.org> | 2010-11-25 12:45:13 +0000 |
commit | 7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b (patch) | |
tree | dd39a8d84f0608dfc932a5e344ccf404c3901215 /apps/plugins/rockboy/rockboy.c | |
parent | 8971b230dcee4140e207d7a36fb769f385cebc82 (diff) | |
download | rockbox-7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b.tar.gz rockbox-7704a3ccd7b1a3d1092bde0a1ec13ba6196b550b.zip |
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
Diffstat (limited to 'apps/plugins/rockboy/rockboy.c')
-rw-r--r-- | apps/plugins/rockboy/rockboy.c | 12 |
1 files changed, 11 insertions, 1 deletions
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) | |||
71 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); | 71 | snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); |
72 | 72 | ||
73 | fd = open(optionsave, O_RDONLY); | 73 | fd = open(optionsave, O_RDONLY); |
74 | if(fd < 0) /* no options to read, set defaults */ | 74 | |
75 | int optionssize = sizeof(options); | ||
76 | int filesize = 0; | ||
77 | if(fd >= 0) | ||
78 | filesize = rb->filesize(fd); | ||
79 | |||
80 | /* don't read the option file if the size | ||
81 | * is not as expected to avoid crash */ | ||
82 | if(fd < 0 || filesize!=optionssize) | ||
75 | { | 83 | { |
84 | // no options to read, set defaults | ||
76 | #ifdef HAVE_TOUCHSCREEN | 85 | #ifdef HAVE_TOUCHSCREEN |
77 | options.LEFT = BUTTON_MIDLEFT; | 86 | options.LEFT = BUTTON_MIDLEFT; |
78 | options.RIGHT = BUTTON_MIDRIGHT; | 87 | options.RIGHT = BUTTON_MIDRIGHT; |
@@ -378,6 +387,7 @@ static int gnuboy_main(const char *rom) | |||
378 | rb->lcd_puts(0,4,"Emu run"); | 387 | rb->lcd_puts(0,4,"Emu run"); |
379 | rb->lcd_clear_display(); | 388 | rb->lcd_clear_display(); |
380 | rb->lcd_update(); | 389 | rb->lcd_update(); |
390 | if(options.autosave) sn_load(); | ||
381 | emu_run(); | 391 | emu_run(); |
382 | 392 | ||
383 | /* never reached */ | 393 | /* never reached */ |