Fail if passed a NULL handler

Before it resulted in an endless recursion.

Resolves https://github.com/cesanta/mongoose/issues/871

CL: Mongoose Web Server: Fail if passed a NULL handler to `mg_bind` or `mg_bind_opt`.

PUBLISHED_FROM=376e5d330a643fa530f6a27a422a1500f986c721
This commit is contained in:
Dmitry Frank 2018-02-02 00:30:27 +02:00 committed by Cesanta Bot
parent 47abc641f1
commit 0ab1c7ef76

View File

@ -3046,6 +3046,11 @@ struct mg_connection *mg_bind_opt(struct mg_mgr *mgr, const char *address,
opts.user_data = user_data;
#endif
if (callback == NULL) {
MG_SET_PTRPTR(opts.error_string, "handler is required");
return NULL;
}
MG_COPY_COMMON_CONNECTION_OPTIONS(&add_sock_opts, &opts);
#if MG_ENABLE_TUN