Skip to content

Commit 5949afc

Browse files
committed
Fix a crash when STA config validation fails
1 parent 5d9f876 commit 5949afc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mgos_wifi_sta.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,13 @@ static void mgos_wifi_reboot_after_ev_handler(int ev, void *evd, void *cb_arg) {
724724
}
725725

726726
bool mgos_wifi_sta_add_cfg(const struct mgos_config_wifi_sta *cfg) {
727+
char *err_msg = NULL;
727728
if (!cfg->enable) return false;
728-
if (!mgos_wifi_validate_sta_cfg(cfg, NULL)) return false;
729+
if (!mgos_wifi_validate_sta_cfg(cfg, &err_msg)) {
730+
LOG(LL_ERROR, ("WiFi STA: %s", err_msg));
731+
free(err_msg);
732+
return false;
733+
}
729734
struct mgos_config_wifi_sta *cfg2;
730735
if (is_sys_cfg(cfg)) {
731736
cfg2 = (struct mgos_config_wifi_sta *) cfg;

0 commit comments

Comments
 (0)