radio-settings: Fix potential leak

rs->imsi is only freed when rs->settings is true.  So tweak the logic
inside radio_load_settings to only strdup the imsi when settings
creation has succeeded.
This commit is contained in:
Denis Kenzior 2016-04-07 09:19:13 -05:00
parent 77a3c58148
commit b708f9f6b3
1 changed files with 3 additions and 2 deletions

View File

@ -811,8 +811,7 @@ static void radio_load_settings(struct ofono_radio_settings *rs,
GError *error;
char *strmode;
rs->imsi = g_strdup(imsi);
rs->settings = storage_open(rs->imsi, SETTINGS_STORE);
rs->settings = storage_open(imsi, SETTINGS_STORE);
/*
* If no settings present or error; Set default.
@ -824,6 +823,8 @@ static void radio_load_settings(struct ofono_radio_settings *rs,
return;
}
rs->imsi = g_strdup(imsi);
error = NULL;
strmode = g_key_file_get_string(rs->settings, SETTINGS_GROUP,
"TechnologyPreference", &error);