From: Russell Bryant Date: Fri, 31 Mar 2006 19:14:28 +0000 (+0000) Subject: move a NULL check to before the first time the pointer is dereferenced (issue #6832) X-Git-Tag: 1.4.0-beta1~2200 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e536a9c6df01365218c8a881c7d40c8f9886327a;p=thirdparty%2Fasterisk.git move a NULL check to before the first time the pointer is dereferenced (issue #6832) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16772 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 6c07d47879..4d6a59f837 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1611,6 +1611,8 @@ static int send_packet(struct iax_frame *f) int callno = f->callno; /* Called with iaxsl held */ + if (!iaxs[callno]) + return -1; if (option_debug > 2 && iaxdebug) ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port)); /* Don't send if there was an error, but return error instead */ @@ -1618,8 +1620,6 @@ static int send_packet(struct iax_frame *f) ast_log(LOG_WARNING, "Call number = %d\n", callno); return -1; } - if (!iaxs[callno]) - return -1; if (iaxs[callno]->error) return -1; if (f->transfer) {