summaryrefslogtreecommitdiff
path: root/main/sdp.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-04-14 11:52:33 -0500
committerRichard Mudgett <rmudgett@digium.com>2017-04-27 19:08:05 -0500
commit176123e76c1705c2cc3247dcd0e15bbb060e7d9b (patch)
tree676a949ae89ac4291dadf7edc3835c9ade3faeba /main/sdp.c
parentbad091b31761f1f29ae734b5dc2a85a3d9837bbc (diff)
SDP: Misc cleanups (Mostly memory leaks)
Change-Id: I74431b385da333f2c5f5a6d7c55e70b69a4f05d2
Diffstat (limited to 'main/sdp.c')
-rw-r--r--main/sdp.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/main/sdp.c b/main/sdp.c
index dc6afe7d8..62acdd3f7 100644
--- a/main/sdp.c
+++ b/main/sdp.c
@@ -435,19 +435,25 @@ static int sdp_m_add_fmtp(struct ast_sdp_m_line *m_line, const struct ast_format
int rtp_code)
{
struct ast_str *fmtp0 = ast_str_alloca(256);
+ struct ast_sdp_a_line *a_line;
char *tmp;
ast_format_generate_sdp_fmtp(format, rtp_code, &fmtp0);
if (ast_str_strlen(fmtp0) == 0) {
- return -1;
+ /* Format doesn't have fmtp attributes */
+ return 0;
}
tmp = ast_str_buffer(fmtp0) + ast_str_strlen(fmtp0) - 1;
- /* remove any carriage return line feeds */
+ /* remove any carriage return line feeds */
while (*tmp == '\r' || *tmp == '\n') --tmp;
*++tmp = '\0';
- /* ast...generate gives us everything, just need value */
+ /*
+ * ast...generate gives us everything, just need value
+ *
+ * It can also give multiple fmtp attribute lines. (silk does)
+ */
tmp = strchr(ast_str_buffer(fmtp0), ':');
if (tmp && tmp[1] != '\0') {
tmp++;
@@ -455,7 +461,10 @@ static int sdp_m_add_fmtp(struct ast_sdp_m_line *m_line, const struct ast_format
tmp = ast_str_buffer(fmtp0);
}
- ast_sdp_m_add_a(m_line, ast_sdp_a_alloc("fmtp", tmp));
+ a_line = ast_sdp_a_alloc("fmtp", tmp);
+ if (!a_line || ast_sdp_m_add_a(m_line, a_line)) {
+ return -1;
+ }
return 0;
}
@@ -495,10 +504,8 @@ static int sdp_m_add_rtpmap(struct ast_sdp_m_line *m_line,
int ast_sdp_m_add_format(struct ast_sdp_m_line *m_line, const struct ast_sdp_options *options,
int rtp_code, int asterisk_format, const struct ast_format *format, int code)
{
- sdp_m_add_rtpmap(m_line, options, rtp_code, asterisk_format, format, code);
- sdp_m_add_fmtp(m_line, format, rtp_code);
-
- return 0;
+ return sdp_m_add_rtpmap(m_line, options, rtp_code, asterisk_format, format, code)
+ || sdp_m_add_fmtp(m_line, format, rtp_code) ? -1 : 0;
}
static struct ast_sdp_a_line *sdp_find_attribute_common(const struct ast_sdp_a_lines *a_lines,