Index: channels/sip/route.c =================================================================== --- channels/sip/route.c (revision 407935) +++ channels/sip/route.c (working copy) @@ -175,8 +175,13 @@ i++; } - if (formatcli && i <= 0) { - ast_str_append(&buf, 0, "N/A"); + if (i <= 0) { + if (formatcli) { + ast_str_append(&buf, 0, "N/A"); + } else if (skip) { + ast_free(buf); + return NULL; + } } return buf; Index: channels/sip/include/route.h =================================================================== --- channels/sip/include/route.h (revision 407935) +++ channels/sip/include/route.h (working copy) @@ -96,6 +96,7 @@ * * \retval an allocated struct ast_str on success * \retval NULL on failure + * \retval NULL when formatcli and skip are non-zero and list no hops */ struct ast_str *sip_route_list(const struct sip_route *route, int formatcli, int skip) __attribute_malloc__ __attribute_warn_unused_result__;