diff --git a/mongoose.h b/mongoose.h index 539411a4..a2137b6a 100644 --- a/mongoose.h +++ b/mongoose.h @@ -3351,7 +3351,11 @@ static inline void mg_dash_ev_handler(struct mg_connection *c, int ev, // Add this to automatically handle "get" and "set" JSON-RPC calls struct mg_dash *dash = (struct mg_dash *) c->fn_data; struct mg_ws_message *wm = (struct mg_ws_message *) ev_data; - mg_dash_process_msg(c, wm, dash->fields, dash->get, dash->set); + if (dash == NULL || dash->fields == NULL) { + mg_dash_error(c, wm->data, "%s", "no fields defined"); + } else { + mg_dash_process_msg(c, wm, dash->fields, dash->get, dash->set); + } } } // Copyright (c) 2023 Cesanta Software Limited diff --git a/src/dash.h b/src/dash.h index 154592e6..8f6a0add 100644 --- a/src/dash.h +++ b/src/dash.h @@ -213,6 +213,10 @@ static inline void mg_dash_ev_handler(struct mg_connection *c, int ev, // Add this to automatically handle "get" and "set" JSON-RPC calls struct mg_dash *dash = (struct mg_dash *) c->fn_data; struct mg_ws_message *wm = (struct mg_ws_message *) ev_data; - mg_dash_process_msg(c, wm, dash->fields, dash->get, dash->set); + if (dash == NULL || dash->fields == NULL) { + mg_dash_error(c, wm->data, "%s", "no fields defined"); + } else { + mg_dash_process_msg(c, wm, dash->fields, dash->get, dash->set); + } } }