Commit 0b4f0dda51 for asterisk.org

commit 0b4f0dda516d5a32da86be9a21c6ea6e1d34eac5
Author: AbdurahmanZA <admin@abdurahman.co.za>
Date:   Mon Oct 26 15:12:49 2026 +0200

    extension_state: Fix crash when a hint loses its presence sources.

    If an existing hint with a presence part ("devices,presence") was
    updated to a hint without one, extension_state_update_sources()
    passed a NULL presence_state_sources to strcmp() and crashed.

    This is triggered by "dialplan add extension <exten>,hint,... replace"
    from the CLI or the AMI Command action, because pbx_config always
    places the presence part in the application data, and by a dialplan
    reload that removes the presence part of a hint.

    The presence sources are now compared NULL-safely.

    Fixes: #2257

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/main/extension_state.c b/main/extension_state.c
index e5e89affdd..9ca4883bf5 100644
--- a/main/extension_state.c
+++ b/main/extension_state.c
@@ -657,8 +657,7 @@ static int extension_state_update_sources(struct extension_state *state, struct
 	}

 	/* If the presence state has changed, create a new snapshot */
-	if ((!state->presence_sources_string && presence_state_sources) ||
-		(state->presence_sources_string && strcmp(state->presence_sources_string, presence_state_sources))) {
+	if (strcmp(S_OR(state->presence_sources_string, ""), S_OR(presence_state_sources, ""))) {
 		enum ast_presence_state presence_state = AST_PRESENCE_NOT_SET;
 		char *presence_subtype = NULL, *presence_message = NULL;