Index: channels/h323/ast_h323.cpp =================================================================== --- channels/h323/ast_h323.cpp (revisión: 18552) +++ channels/h323/ast_h323.cpp (copia de trabajo) @@ -1053,9 +1053,10 @@ : H323_ExternalRTPChannel::H323_ExternalRTPChannel(connection, capability, direction, id) { struct rtp_info *info; + info = (struct rtp_info *)malloc(sizeof(struct rtp_info)); /* Determine the Local (A side) IP Address and port */ - info = on_external_rtp_create(connection.GetCallReference(), (const char *)connection.GetCallToken()); + info = on_external_rtp_create(connection.GetCallReference(), (const char *)connection.GetCallToken(), info); if (!info) { cout << "\tERROR: on_external_rtp_create failure" << endl; return; Index: channels/h323/chan_h323.h =================================================================== --- channels/h323/chan_h323.h (revisión: 18552) +++ channels/h323/chan_h323.h (copia de trabajo) @@ -112,7 +112,7 @@ /* This is a callback prototype function, called to collect the external RTP port from Asterisk. */ -typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *); +typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *, struct rtp_info *); extern on_rtp_cb on_external_rtp_create; /* This is a callback prototype function, called to send Index: channels/chan_h323.c =================================================================== --- channels/chan_h323.c (revisión: 18552) +++ channels/chan_h323.c (copia de trabajo) @@ -820,14 +820,16 @@ ast_rtp_settos(pvt->rtp, tos); ast_mutex_init(&pvt->lock); /* Ensure the call token is allocated */ - if ((pvt->cd).call_token == NULL) { - (pvt->cd).call_token = (char *)malloc(128); + if (callid == 0) { + if ((pvt->cd).call_token == NULL) { + (pvt->cd).call_token = (char *)malloc(128); + } + if (!pvt->cd.call_token) { + ast_log(LOG_ERROR, "Not enough memory to alocate call token\n"); + return NULL; + } + memset((char *)(pvt->cd).call_token, 0, 128); } - if (!pvt->cd.call_token) { - ast_log(LOG_ERROR, "Not enough memory to alocate call token\n"); - return NULL; - } - memset((char *)(pvt->cd).call_token, 0, 128); pvt->cd.call_reference = callid; memcpy(&pvt->options, &global_options, sizeof(pvt->options)); if (pvt->options.dtmfmode & H323_DTMF_RFC2833) { @@ -1138,20 +1140,17 @@ * * Returns the local RTP information */ -struct rtp_info *external_rtp_create(unsigned call_reference, const char * token) +struct rtp_info *external_rtp_create(unsigned call_reference, const char * token, struct rtp_info *info) { struct oh323_pvt *pvt; struct sockaddr_in us; - struct rtp_info *info; - info = (struct rtp_info *)malloc(sizeof(struct rtp_info)); if (!info) { ast_log(LOG_ERROR, "Unable to allocated info structure, this is very bad\n"); return NULL; } pvt = find_call_locked(call_reference, token); if (!pvt) { - free(info); ast_log(LOG_ERROR, "Unable to find call %s(%d)\n", token, call_reference); return NULL; }