Skip to content

Commit

Permalink
Guard against return value already being null
Browse files Browse the repository at this point in the history
If there is no retrieved parameter, we should not de-reference null

Bug: 27748546
Change-Id: I8e6ceba26ab7d73ab365b72c0bfdcdb0a36a59a7
  • Loading branch information
pstew-dd authored and andi34 committed Jun 7, 2016
1 parent 3fd5d95 commit 0ae423e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wpa_supplicant/config.c
Expand Up @@ -2218,8 +2218,10 @@ char * wpa_config_get(struct wpa_ssid *ssid, const char *var)
const struct parse_data *field = &ssid_fields[i];
if (os_strcmp(var, field->name) == 0) {
char *ret = field->writer(field, ssid);
if (os_strchr(ret, '\r') != NULL || os_strchr(ret, '\n') != NULL) {
wpa_printf(MSG_ERROR, "Found newline in value for %s; "
if (ret != NULL && (os_strchr(ret, '\r') != NULL ||
os_strchr(ret, '\n') != NULL)) {
wpa_printf(MSG_ERROR,
"Found newline in value for %s; "
"not returning it", var);
os_free(ret);
ret = NULL;
Expand Down

0 comments on commit 0ae423e

Please sign in to comment.