sdp_msg: when NULL, do not crash but return empty SDP str

Change-Id: Ibd5c43fae61cd006d8fb42a06b99a609356f7037
This commit is contained in:
Neels Hofmeyr 2022-09-05 16:02:50 +02:00
parent 0b29968196
commit 90b80e8591
1 changed files with 10 additions and 2 deletions

View File

@ -240,8 +240,16 @@ int sdp_msg_to_sdp_str_buf(char *dst, size_t dst_size, const struct sdp_msg *sdp
{
const struct sdp_audio_codec *codec;
struct osmo_strbuf sb = { .buf = dst, .len = dst_size };
const char *ip = sdp->rtp.ip[0] ? sdp->rtp.ip : "0.0.0.0";
char ipv = osmo_ip_str_type(ip) == AF_INET6 ? '6' : '4';
const char *ip;
char ipv;
if (!sdp) {
OSMO_STRBUF_PRINTF(sb, "%s", "");
return sb.chars_needed;
}
ip = sdp->rtp.ip[0] ? sdp->rtp.ip : "0.0.0.0";
ipv = (osmo_ip_str_type(ip) == AF_INET6) ? '6' : '4';
OSMO_STRBUF_PRINTF(sb,
"v=0\r\n"