[libpri-commits] rmudgett: branch 1.4 r2233 - /branches/1.4/q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon Feb 28 17:39:34 CST 2011


Author: rmudgett
Date: Mon Feb 28 17:39:30 2011
New Revision: 2233

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2233
Log:
Fix valgrind reported invalid read/write for display text feature.

Modified:
    branches/1.4/q931.c

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=2233&r1=2232&r2=2233
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Mon Feb 28 17:39:30 2011
@@ -7194,6 +7194,7 @@
 	case MAINTENANCE_PROTOCOL_DISCRIMINATOR_1:
 	case MAINTENANCE_PROTOCOL_DISCRIMINATOR_2:
 		res = post_handle_maintenance_message(ctrl, h->pd, mh, c);
+		q931_display_clear(c);
 		break;
 	default:
 		allow_event = 1;
@@ -7212,12 +7213,11 @@
 				res = 0;
 			}
 		} else {
+			q931_display_clear(c);
 			res = 0;
 		}
 		break;
 	}
-	q931_display_subcmd(ctrl, c);
-	q931_display_clear(c);
 	return res;
 }
 
@@ -7961,6 +7961,10 @@
  * \param c Q.931 call leg.
  * \param missingmand Number of missing mandatory ie's.
  *
+ * \note
+ * When this function returns c may be destroyed so you can no
+ * longer dereference it.
+ *
  * \retval 0 if no error or event.
  * \retval Q931_RES_HAVEEVENT if have an event.
  * \retval -1 on error.
@@ -7975,6 +7979,7 @@
 
 	switch(mh->msg) {
 	case Q931_RESTART:
+		q931_display_subcmd(ctrl, c);
 		if (missingmand) {
 			q931_status(ctrl, c, PRI_CAUSE_MANDATORY_IE_MISSING);
 			pri_destroycall(ctrl, c);
@@ -7989,6 +7994,8 @@
 		ctrl->ev.restart.channel = q931_encode_channel(c);
 		return Q931_RES_HAVEEVENT;
 	case Q931_REGISTER:
+		q931_display_subcmd(ctrl, c);
+
 		/* Must be new call */
 		if (!c->newcall) {
 			q931_status(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE);
@@ -8018,6 +8025,8 @@
 		q931_fill_ring_event(ctrl, c);
 		return Q931_RES_HAVEEVENT;
 	case Q931_SETUP:
+		q931_display_subcmd(ctrl, c);
+
 		if (missingmand) {
 			q931_release_complete(ctrl, c, PRI_CAUSE_MANDATORY_IE_MISSING);
 			break;
@@ -8061,6 +8070,7 @@
 		q931_fill_ring_event(ctrl, c);
 		return Q931_RES_HAVEEVENT;
 	case Q931_ALERTING:
+		q931_display_subcmd(ctrl, c);
 		stop_t303(c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
@@ -8096,6 +8106,7 @@
 
 		return Q931_RES_HAVEEVENT;
 	case Q931_CONNECT:
+		q931_display_subcmd(ctrl, c);
 		stop_t303(c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
@@ -8151,6 +8162,7 @@
 		}
 		break;
 	case Q931_FACILITY:
+		q931_display_subcmd(ctrl, c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
 			break;
@@ -8167,7 +8179,6 @@
 		default:
 			break;
 		}
-		q931_display_subcmd(ctrl, c);
 		if (ctrl->subcmds.counter_subcmd) {
 			q931_fill_facility_event(ctrl, c);
 			return Q931_RES_HAVEEVENT;
@@ -8183,6 +8194,7 @@
 		ctrl->ev.proceeding.cause = c->cause;
 		/* Fall through */
 	case Q931_CALL_PROCEEDING:
+		q931_display_subcmd(ctrl, c);
 		stop_t303(c);
 		ctrl->ev.proceeding.subcmds = &ctrl->subcmds;
 		if (c->newcall) {
@@ -8215,6 +8227,7 @@
 		}
 		return Q931_RES_HAVEEVENT;
 	case Q931_CONNECT_ACKNOWLEDGE:
+		q931_display_subcmd(ctrl, c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
 			break;
@@ -8241,6 +8254,7 @@
 		}
 		break;
 	case Q931_STATUS:
+		q931_display_subcmd(ctrl, c);
 		if (missingmand) {
 			q931_status(ctrl, c, PRI_CAUSE_MANDATORY_IE_MISSING);
 			pri_destroycall(ctrl, c);
@@ -8303,6 +8317,7 @@
 		}
 		break;
 	case Q931_RELEASE_COMPLETE:
+		q931_display_subcmd(ctrl, c);
 		c->hangupinitiated = 1;
 		UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_NULL);
 		c->peercallstate = Q931_CALL_STATE_NULL;
@@ -8340,6 +8355,7 @@
 			pri_hangup(ctrl,c,c->cause);
 		break;
 	case Q931_RELEASE:
+		q931_display_subcmd(ctrl, c);
 		c->hangupinitiated = 1;
 		if (missingmand) {
 			/* Force cause to be mandatory IE missing */
@@ -8381,6 +8397,7 @@
 		}
 		return Q931_RES_HAVEEVENT;
 	case Q931_DISCONNECT:
+		q931_display_subcmd(ctrl, c);
 		c->hangupinitiated = 1;
 		if (missingmand) {
 			/* Still let user call release */
@@ -8479,6 +8496,7 @@
 		}
 		break;
 	case Q931_RESTART_ACKNOWLEDGE:
+		q931_display_subcmd(ctrl, c);
 		UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_NULL);
 		c->peercallstate = Q931_CALL_STATE_NULL;
 		ctrl->ev.e = PRI_EVENT_RESTART_ACK;
@@ -8489,6 +8507,7 @@
 		       overlap dialing received digit
 		       +  the "Complete" msg which is basically an EOF on further digits
 		   XXX */
+		q931_display_subcmd(ctrl, c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
 			break;
@@ -8518,12 +8537,14 @@
 		ctrl->ev.ring.complete = c->complete;	/* this covers IE 33 (Sending Complete) */
 		return Q931_RES_HAVEEVENT;
 	case Q931_STATUS_ENQUIRY:
+		q931_display_clear(c);
 		if (c->newcall) {
 			q931_release_complete(ctrl, c, PRI_CAUSE_INVALID_CALL_REFERENCE);
 		} else
 			q931_status(ctrl,c, PRI_CAUSE_RESPONSE_TO_STATUS_ENQUIRY);
 		break;
 	case Q931_SETUP_ACKNOWLEDGE:
+		q931_display_subcmd(ctrl, c);
 		stop_t303(c);
 		if (c->newcall) {
 			q931_release_complete(ctrl,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
@@ -8638,8 +8659,10 @@
 			res = Q931_RES_HAVEEVENT;
 			break;
 		}
+		q931_display_subcmd(ctrl, c);
 		return res;
 	case Q931_HOLD:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		if (!ctrl->hold_support) {
 			/*
@@ -8705,6 +8728,7 @@
 		}
 		return res;
 	case Q931_HOLD_ACKNOWLEDGE:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		master_call = c->master_call;
 		switch (master_call->hold_state) {
@@ -8733,6 +8757,7 @@
 		}
 		return res;
 	case Q931_HOLD_REJECT:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		master_call = c->master_call;
 		switch (master_call->hold_state) {
@@ -8760,6 +8785,7 @@
 		}
 		return res;
 	case Q931_RETRIEVE:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		switch (c->ourcallstate) {
 		case Q931_CALL_STATE_CALL_RECEIVED:
@@ -8818,6 +8844,7 @@
 		}
 		return res;
 	case Q931_RETRIEVE_ACKNOWLEDGE:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		master_call = c->master_call;
 		switch (master_call->hold_state) {
@@ -8840,6 +8867,7 @@
 		}
 		return res;
 	case Q931_RETRIEVE_REJECT:
+		q931_display_subcmd(ctrl, c);
 		res = 0;
 		master_call = c->master_call;
 		switch (master_call->hold_state) {
@@ -8889,6 +8917,7 @@
 	default:
 		pri_error(ctrl, "!! Don't know how to post-handle message type %s (0x%X)\n",
 			msg2str(mh->msg), mh->msg);
+		q931_display_clear(c);
 		q931_status(ctrl,c, PRI_CAUSE_MESSAGE_TYPE_NONEXIST);
 		if (!c->master_call->outboundbroadcast && c->newcall) {
 			/*




More information about the libpri-commits mailing list