Index: res/res_rtp_asterisk.c =================================================================== --- res/res_rtp_asterisk.c (revision 385881) +++ res/res_rtp_asterisk.c (working copy) @@ -749,7 +749,7 @@ { struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); struct ast_sockaddr remote_address = { {0,} }; - int hdrlen = 12, res = 0, i = 0; + int hdrlen = 12, res = -1, i = 0; char data[256]; unsigned int *rtpheader = (unsigned int*)data; unsigned int measured_samples; @@ -758,7 +758,7 @@ /* Make sure we know where the remote side is so we can send them the packet we construct */ if (ast_sockaddr_isnull(&remote_address)) { - return -1; + goto cleanup; } /* Convert the given digit to the one we are going to send */ @@ -774,7 +774,7 @@ digit = digit - 'a' + 12; } else { ast_log(LOG_WARNING, "Don't know how to represent '%c'\n", digit); - return -1; + goto cleanup; } rtp->dtmfmute = ast_tvadd(ast_tvnow(), ast_tv(0, 500000)); @@ -809,13 +809,15 @@ rtp->seqno++; } + res = 0; /* Oh and we can't forget to turn off the stuff that says we are sending DTMF */ rtp->lastts += rtp->send_duration; +cleanup: rtp->sending_digit = 0; rtp->send_digit = 0; - return 0; + return res; } static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit)