Related to ticket #411 (Cannot update account presence's status while previous PUBLISH is in progress):
 - Crash in timer if publication session is terminated prematurely. To reproduce: publish two events in quick successions, e.g. by pressing "t" in pjsua couple of times. The publication session will be terminated with PJ_EBUSY status, and crash may occur when timer heap is polled.



git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2939 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-simple/publishc.c b/pjsip/src/pjsip-simple/publishc.c
index 0e9c073..6ba867a 100644
--- a/pjsip/src/pjsip-simple/publishc.c
+++ b/pjsip/src/pjsip-simple/publishc.c
@@ -174,6 +174,12 @@
 	pubc->_delete_flag = 1;
 	pubc->cb = NULL;
     } else {
+	/* Cancel existing timer, if any */
+	if (pubc->timer.id != 0) {
+	    pjsip_endpt_cancel_timer(pubc->endpt, &pubc->timer);
+	    pubc->timer.id = 0;
+	}
+
 	pjsip_endpt_release_pool(pubc->endpt, pubc->pool);
     }