mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
plugins: clock: fix fd not closed when file size differs
Change-Id: I12716c650703c47f8db825b1ae7e6fe62c039258
This commit is contained in:
parent
1812d15416
commit
2d00292df5
1 changed files with 7 additions and 3 deletions
|
|
@ -102,9 +102,13 @@ void clock_settings_skin_previous(struct clock_settings* settings){
|
||||||
static enum settings_file_status clock_settings_load(
|
static enum settings_file_status clock_settings_load(
|
||||||
struct clock_settings* settings,char* filename){
|
struct clock_settings* settings,char* filename){
|
||||||
int fd = rb->open(filename, O_RDONLY);
|
int fd = rb->open(filename, O_RDONLY);
|
||||||
if(fd >= 0){ /* does file exist? */
|
if(fd >= 0)
|
||||||
|
{
|
||||||
/* basic consistency check */
|
/* basic consistency check */
|
||||||
if(rb->filesize(fd) == sizeof(*settings)){
|
if(rb->filesize(fd) != sizeof(*settings))
|
||||||
|
rb->close(fd);
|
||||||
|
else
|
||||||
|
{
|
||||||
rb->read(fd, settings, sizeof(*settings));
|
rb->read(fd, settings, sizeof(*settings));
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
apply_backlight_setting(settings->general.backlight);
|
apply_backlight_setting(settings->general.backlight);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue