wpa_supplicant: Free config only if it was allocated in same call

If option -I:config points to a non-existing file, the the previously
allocated config must not be freed. Avoid use of freed memory in such an
error case by skipping the incorrect freeing operation.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
Dmitry Shmidt 2018-02-01 00:34:54 +00:00 committed by Jouni Malinen
parent 946ed13c98
commit 9c5fe742a2

View file

@ -397,7 +397,8 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
if (f == NULL) {
wpa_printf(MSG_ERROR, "Failed to open config file '%s', "
"error: %s", name, strerror(errno));
os_free(config);
if (config != cfgp)
os_free(config);
return NULL;
}