]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
stasis_channels.c: Add null check for referred_by in ast_ari_transfer_message_create
authorSven Kube <mail@sven-kube.de>
Thu, 18 Sep 2025 06:26:33 +0000 (08:26 +0200)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Mon, 22 Sep 2025 17:26:50 +0000 (17:26 +0000)
When handling SIP transfers via ARI, the `referred_by` field in
`transfer_ari_state` may be null, since SIP REFER requests are not
required to include a `Referred-By` header. Without this check, a null
value caused the transfer to fail and triggered a NOTIFY with a 500
Internal Server Error.

main/stasis_channels.c

index 4e712e03ae91ada4dd154fa39dbeb0694b52b464..76173aa35212cd614592bfba0c5aa8177be16046 100644 (file)
@@ -1797,11 +1797,14 @@ struct ast_ari_transfer_message *ast_ari_transfer_message_create(struct ast_chan
                }
        }
 
-       msg->referred_by = ast_strdup(referred_by);
-       if (!msg->referred_by) {
-               ao2_cleanup(msg);
-               return NULL;
+       if (referred_by) {
+               msg->referred_by = ast_strdup(referred_by);
+               if (!msg->referred_by) {
+                       ao2_cleanup(msg);
+                       return NULL;
+               }
        }
+
        ast_copy_string(msg->destination, exten, sizeof(msg->destination));
        msg->protocol_id = ast_strdup(protocol_id);
        if (!msg->protocol_id) {