Index: apps/app_meetme.c
===================================================================
--- apps/app_meetme.c	(revision 295123)
+++ apps/app_meetme.c	(working copy)
@@ -2623,8 +2623,11 @@
 	if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) ||
 		ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) {
 		struct announce_listitem *item;
-		if (!(item = ao2_alloc(sizeof(*item), NULL)))
-			return -1;
+		if (!(item = ao2_alloc(sizeof(*item), NULL))) {
+			ret = -1;
+                        goto outrun;
+		}
+
 		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
 		ast_copy_string(item->language, chan->language, sizeof(item->language));
 		item->confchan = conf->chan;
@@ -3206,7 +3209,7 @@
 									}
 								}
 								user_iter = ao2_iterator_init(conf->usercontainer, 0);
-								while((user = ao2_iterator_next(&user_iter))) {
+								while((usr = ao2_iterator_next(&user_iter))) {
 									if (ast_fileexists(usr->namerecloc, NULL, NULL)) {
 										if (keepplaying && !ast_streamfile(chan, usr->namerecloc, chan->language)) {
 											res = ast_waitstream(chan, AST_DIGIT_ANY);
@@ -3216,7 +3219,7 @@
 										}
 										playednamerec = 1;
 									}
-									ao2_ref(user, -1);
+									ao2_ref(usr, -1);
 								}
 								ao2_iterator_destroy(&user_iter);
 								if (keepplaying && playednamerec && !ast_streamfile(chan, "conf-roll-callcomplete", chan->language)) {
@@ -3371,7 +3374,7 @@
 								} else {
 									usr->adminflags |= ADMINFLAG_KICKME;
 								}
-								ao2_ref(user, -1);
+								ao2_ref(usr, -1);
 								ast_stopstream(chan);
 								break;	
 							}
@@ -3672,8 +3675,12 @@
 
 	if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) {
 		struct announce_listitem *item;
-		if (!(item = ao2_alloc(sizeof(*item), NULL)))
-			return -1;
+
+		if (!(item = ao2_alloc(sizeof(*item), NULL))) {
+			ret = -1;
+			goto outrun;
+		}
+
 		ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc));
 		ast_copy_string(item->language, chan->language, sizeof(item->language));
 		item->confchan = conf->chan;
@@ -3695,63 +3702,63 @@
 	if (dsp) {
 		ast_dsp_free(dsp);
 	}
-	
-	if (!user->user_no) {
-		ao2_ref(user, -1);
-	} else { /* Only cleanup users who really joined! */
-		now = ast_tvnow();
-		hr = (now.tv_sec - user->jointime) / 3600;
-		min = ((now.tv_sec - user->jointime) % 3600) / 60;
-		sec = (now.tv_sec - user->jointime) % 60;
 
-		if (sent_event) {
-			ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
-				"Channel: %s\r\n"
-				"Uniqueid: %s\r\n"
-				"Meetme: %s\r\n"
-				"Usernum: %d\r\n"
-				"CallerIDNum: %s\r\n"
-				"CallerIDName: %s\r\n"
-				"Duration: %ld\r\n",
-				chan->name, chan->uniqueid, conf->confno,
-				user->user_no,
-				S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
-				S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
-				(long)(now.tv_sec - user->jointime));
-		}
+	now = ast_tvnow();
+	hr = (now.tv_sec - user->jointime) / 3600;
+	min = ((now.tv_sec - user->jointime) % 3600) / 60;
+	sec = (now.tv_sec - user->jointime) % 60;
 
-		if (setusercount) {
-			conf->users--;
-			if (rt_log_members) {
-				/* Update table */
-				snprintf(members, sizeof(members), "%d", conf->users);
-				ast_realtime_require_field("meetme",
-					"confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno),
-					"members", RQ_UINTEGER1, strlen(members),
-					NULL);
-				ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL);
-			}
-			if (ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) {
-				conf->markedusers--;
-			}
-		}
-		/* Remove ourselves from the container */
-		ao2_unlink(conf->usercontainer, user); 
+	if (sent_event) {
+		ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
+			"Channel: %s\r\n"
+			"Uniqueid: %s\r\n"
+			"Meetme: %s\r\n"
+			"Usernum: %d\r\n"
+			"CallerIDNum: %s\r\n"
+			"CallerIDName: %s\r\n"
+			"Duration: %ld\r\n",
+			chan->name, chan->uniqueid, conf->confno,
+			user->user_no,
+			S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
+			S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
+			(long)(now.tv_sec - user->jointime));
+	}
 
-		/* Change any states */
-		if (!conf->users) {
-			ast_devstate_changed(AST_DEVICE_NOT_INUSE, "meetme:%s", conf->confno);
+	if (setusercount) {
+		conf->users--;
+		if (rt_log_members) {
+			/* Update table */
+			snprintf(members, sizeof(members), "%d", conf->users);
+			ast_realtime_require_field("meetme",
+				"confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno),
+				"members", RQ_UINTEGER1, strlen(members),
+				NULL);
+			ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL);
 		}
+		if (ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) {
+			conf->markedusers--;
+		}
+	}
+	/* Remove ourselves from the container */
+	ao2_unlink(conf->usercontainer, user); 
 
-		/* Return the number of seconds the user was in the conf */
-		snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime));
-		pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
+	/* This user is no longer in the meetme */
+	ao2_ref(user, -1);
 
-		/* Return the RealTime bookid for CDR linking */
-		if (rt_schedule) {
-			pbx_builtin_setvar_helper(chan, "MEETMEBOOKID", conf->bookid);
-		}
+	/* Change any states */
+	if (!conf->users) {
+		ast_devstate_changed(AST_DEVICE_NOT_INUSE, "meetme:%s", conf->confno);
 	}
+
+	/* Return the number of seconds the user was in the conf */
+	snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime));
+	pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
+
+	/* Return the RealTime bookid for CDR linking */
+	if (rt_schedule) {
+		pbx_builtin_setvar_helper(chan, "MEETMEBOOKID", conf->bookid);
+	}
+
 	AST_LIST_UNLOCK(&confs);
 
 	return ret;
