From c0b3c923a46afc12837698a78a11b17a7fc384d8 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Mon, 9 Nov 2009 07:37:52 +0000 Subject: Fix various problems detected with Valgrind. * chan_console accessed pvts after deallocation. * cdr_mysql stored a pointer that was freed by realloc() * The module loader did not check usecount on shutdown, which led to chan_iax2 reading a timer that was already unloaded. * The event subsystem sometimes creates an event with no IEs. Due to a corner condition, the code would read beyond the memory boundary. * res_pktccops did not correctly check whether its monitor thread was started. (closes issue #16062) Reported by: alexanderheinz Patches: 20091109__issue16062.diff.txt uploaded by tilghman (license 14) Tested by: tilghman git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228798 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/event.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'main/event.c') diff --git a/main/event.c b/main/event.c index 070048b4b..cc2efe961 100644 --- a/main/event.c +++ b/main/event.c @@ -1067,6 +1067,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) struct ast_event *event; enum ast_event_ie_type ie_type; struct ast_event_ie_val *ie_val; + int has_ie = 0; AST_LIST_HEAD_NOLOCK_STATIC(ie_vals, ast_event_ie_val); /* Invalid type */ @@ -1114,6 +1115,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) if (insert) { AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry); + has_ie = 1; } } va_end(ap); @@ -1154,7 +1156,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...) } } - if (!ast_event_get_ie_raw(event, AST_EVENT_IE_EID)) { + if (has_ie && !ast_event_get_ie_raw(event, AST_EVENT_IE_EID)) { /* If the event is originating on this server, add the server's * entity ID to the event. */ ast_event_append_ie_raw(&event, AST_EVENT_IE_EID, &ast_eid_default, sizeof(ast_eid_default)); -- cgit v1.2.3