diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 4565329b..c952c29d 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -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;