Module: kamailio Branch: master Commit: 7ae5210a7b9fb2d9a61cef496e9abe0da9860bee URL: https://github.com/kamailio/kamailio/commit/7ae5210a7b9fb2d9a61cef496e9abe0da9860bee
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2017-03-17T07:52:57+01:00 jsonrpcs: safety check to see if xhttp transport was initialized - reported by GH #1030 --- Modified: src/modules/jsonrpcs/jsonrpcs_mod.c --- Diff: https://github.com/kamailio/kamailio/commit/7ae5210a7b9fb2d9a61cef496e9abe0da9860bee.diff Patch: https://github.com/kamailio/kamailio/commit/7ae5210a7b9fb2d9a61cef496e9abe0da9860bee.patch --- diff --git a/src/modules/jsonrpcs/jsonrpcs_mod.c b/src/modules/jsonrpcs/jsonrpcs_mod.c index e639ab9..34f5f64 100644 --- a/src/modules/jsonrpcs/jsonrpcs_mod.c +++ b/src/modules/jsonrpcs/jsonrpcs_mod.c @@ -1050,11 +1050,12 @@ static void jsonrpc_delayed_ctx_close(struct rpc_delayed_ctx* dctx) static int mod_init(void) { + memset(&xhttp_api, 0, sizeof(xhttp_api_t)); /* bind the XHTTP API */ if(jsonrpc_transport==0 || (jsonrpc_transport&1)) { if (xhttp_load_api(&xhttp_api) < 0) { - if(jsonrpc_transport==1) { + if(jsonrpc_transport&1) { LM_ERR("cannot bind to XHTTP API\n"); return -1; } else { @@ -1169,6 +1170,11 @@ static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2) return NONSIP_MSG_PASS; } + if(xhttp_api.reply==NULL) { + LM_ERR("jsonrpc over http not initialized - check transport param\n"); + return NONSIP_MSG_ERROR; + } + /* initialize jsonrpc context */ ctx = &_jsonrpc_ctx; memset(ctx, 0, sizeof(jsonrpc_ctx_t)); _______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev