From 18713372debe581d9c90295753251c77bdb579ad Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Sat, 11 May 2024 11:24:21 +0200 Subject: [PATCH] Fixed memory leak in janus_sdp_get_codec_pt_full, g_list_free(pts) was not called for early return --- src/sdp-utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sdp-utils.c b/src/sdp-utils.c index 4cd458d1f6..79d5acce4f 100644 --- a/src/sdp-utils.c +++ b/src/sdp-utils.c @@ -808,6 +808,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, co pts = g_list_append(pts, GINT_TO_POINTER(pt)); } else { /* Payload type for codec found */ + g_list_free(pts); return pt; } } @@ -833,6 +834,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, co if(strstr(a->value, profile_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "VP9 profile %s found --> %d\n", profile, pt); + g_list_free(pts); return pt; } } else if(h264 && strstr(a->value, "packetization-mode=0") == NULL) { @@ -844,6 +846,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, co if(strstr(a->value, profile_level_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); + g_list_free(pts); return pt; } /* Not found, try converting the profile to upper case */ @@ -853,6 +856,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, co if(strstr(a->value, profile_level_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); + g_list_free(pts); return pt; } } @@ -860,8 +864,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, co ma = ma->next; } } - if(pts != NULL) - g_list_free(pts); + g_list_free(pts); if(index != -1) break; ml = ml->next;