From b082147c4d89a2856ce06fa0365eb643d71ca89f Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 10 Sep 2015 14:21:27 +0200 Subject: [PATCH] onepad: avoid potential resource leak --- plugins/onepad/Linux/ini.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/onepad/Linux/ini.cpp b/plugins/onepad/Linux/ini.cpp index efcb3a5408..85f8afaa60 100644 --- a/plugins/onepad/Linux/ini.cpp +++ b/plugins/onepad/Linux/ini.cpp @@ -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(); }