onepad: avoid potential resource leak

This commit is contained in:
Gregory Hainaut 2015-09-10 14:21:27 +02:00
parent f4f08b9c99
commit b082147c4d
1 changed files with 8 additions and 6 deletions

View File

@ -171,15 +171,15 @@ void LoadConfig()
}
u32 value;
if (fscanf(f, "log = %d\n", &value) == 0) return;
if (fscanf(f, "log = %d\n", &value) == 0) goto error;
conf->log = value;
if (fscanf(f, "options = %d\n", &value) == 0) return;
if (fscanf(f, "options = %d\n", &value) == 0) goto error;
conf->options = value;
if (fscanf(f, "mouse_sensibility = %d\n", &value) == 0) return;
if (fscanf(f, "mouse_sensibility = %d\n", &value) == 0) goto error;
conf->sensibility = value;
if (fscanf(f, "joy_pad_map = %d\n", &value) == 0) return;
if (fscanf(f, "joy_pad_map = %d\n", &value) == 0) goto error;
conf->joyid_map = value;
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) return;
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) goto error;
conf->ff_intensity = value;
for (int pad = 0; pad < 2; pad++)
@ -203,7 +203,9 @@ void LoadConfig()
if(pad == 0) have_user_setting = true;
}
if (!have_user_setting) DefaultKeyboardValues();
error:
fclose(f);
if (!have_user_setting) DefaultKeyboardValues();
}