From: Ivan Poddubny Date: Mon, 28 Sep 2015 06:36:30 +0000 (+0300) Subject: channel.c: Fix NewCallerid AMI event not been sent on Caller ID change X-Git-Tag: 11.20.0-rc1~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d2e1ecdca3291f0f82aac392bd68deec3c914e5;p=thirdparty%2Fasterisk.git channel.c: Fix NewCallerid AMI event not been sent on Caller ID change Currently, NewCallerid is sent only when pointers to number or name strings change, which is not always the case. The newly allocated string may use the same memory, so pointers match, while the content is different. As a result, Caller ID updates are often not reported. With this patch, actual strings are compared, not the pointers. ASTERISK-25427 #close Reported by: Ivan Poddubny Change-Id: I2a1ac3a842f0e092c6058d1cd3e35443bece1b36 --- diff --git a/main/channel.c b/main/channel.c index f26f8652fa..ef50e94a74 100644 --- a/main/channel.c +++ b/main/channel.c @@ -7388,8 +7388,10 @@ void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_cal void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update) { - const char *pre_set_number; - const char *pre_set_name; + const char *old_number; + const char *old_name; + const char *new_number; + const char *new_name; if (ast_channel_caller(chan) == caller) { /* Don't set to self */ @@ -7397,14 +7399,19 @@ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_par } ast_channel_lock(chan); - pre_set_number = - S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL); - pre_set_name = S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL); + old_number = ast_strdupa(S_COR(ast_channel_caller(chan)->id.number.valid, + ast_channel_caller(chan)->id.number.str, "")); + old_name = ast_strdupa(S_COR(ast_channel_caller(chan)->id.name.valid, + ast_channel_caller(chan)->id.name.str, "")); + ast_party_caller_set(ast_channel_caller(chan), caller, update); - if (S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL) - != pre_set_number - || S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL) - != pre_set_name) { + + new_number = S_COR(ast_channel_caller(chan)->id.number.valid, + ast_channel_caller(chan)->id.number.str, ""); + new_name = S_COR(ast_channel_caller(chan)->id.name.valid, + ast_channel_caller(chan)->id.name.str, ""); + + if (0 != strcmp(old_number, new_number) || 0 != strcmp(old_name, new_name)) { /* The caller id name or number changed. */ report_new_callerid(chan); }