TT#14008 fix possible segfault

closes #1172

Change-Id: I94bb52c290c2032073e54528283660f03e694033
pull/1180/head
Richard Fuchs 5 years ago committed by Damir Nedžibović
parent 1a5bcc0905
commit fbf74bfe2d

@ -99,6 +99,9 @@ static int get_clock_rate(struct media_packet *mp, int payload_type) {
} }
static struct jb_packet* get_jb_packet(struct media_packet *mp, const str *s) { static struct jb_packet* get_jb_packet(struct media_packet *mp, const str *s) {
if (rtp_payload(&mp->rtp, &mp->payload, &mp->raw))
return NULL;
char *buf = malloc(s->len + RTP_BUFFER_HEAD_ROOM + RTP_BUFFER_TAIL_ROOM); char *buf = malloc(s->len + RTP_BUFFER_HEAD_ROOM + RTP_BUFFER_TAIL_ROOM);
if (!buf) { if (!buf) {
ilog(LOG_ERROR, "Failed to allocate memory: %s", strerror(errno)); ilog(LOG_ERROR, "Failed to allocate memory: %s", strerror(errno));
@ -113,11 +116,6 @@ static struct jb_packet* get_jb_packet(struct media_packet *mp, const str *s) {
str_init_len(&p->mp.raw, buf + RTP_BUFFER_HEAD_ROOM, s->len); str_init_len(&p->mp.raw, buf + RTP_BUFFER_HEAD_ROOM, s->len);
memcpy(p->mp.raw.s, s->s, s->len); memcpy(p->mp.raw.s, s->s, s->len);
if(rtp_payload(&p->mp.rtp, &p->mp.payload, &p->mp.raw)) {
jb_packet_free(&p);
return NULL;
}
return p; return p;
} }

@ -1939,9 +1939,12 @@ void media_packet_copy(struct media_packet *dst, const struct media_packet *src)
dst->raw = STR_NULL; dst->raw = STR_NULL;
} }
void media_packet_release(struct media_packet *mp) { void media_packet_release(struct media_packet *mp) {
obj_put(mp->sfd); if (mp->sfd)
obj_put(&mp->ssrc_in->parent->h); obj_put(mp->sfd);
obj_put(&mp->ssrc_out->parent->h); if (mp->ssrc_in)
obj_put(&mp->ssrc_in->parent->h);
if (mp->ssrc_out)
obj_put(&mp->ssrc_out->parent->h);
g_queue_clear_full(&mp->packets_out, codec_packet_free); g_queue_clear_full(&mp->packets_out, codec_packet_free);
g_free(mp->rtp); g_free(mp->rtp);
g_free(mp->rtcp); g_free(mp->rtcp);

Loading…
Cancel
Save