From 502c14a6252f402177248db85ae5456a12894d52 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Thu, 9 May 2024 16:43:09 +0200 Subject: [PATCH] Fixed memory leak in janus_sdp_get_codec_pt_full, g_list_free(pts) was not called for early return --- sdp-utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdp-utils.c b/sdp-utils.c index c06f3bbe78..cf5a6f2af1 100644 --- a/sdp-utils.c +++ b/sdp-utils.c @@ -736,6 +736,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p pts = g_list_append(pts, GINT_TO_POINTER(pt)); } else { /* Payload type for codec found */ + g_list_free(pts); return pt; } } @@ -761,6 +762,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p 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) { @@ -772,6 +774,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p 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 */ @@ -781,6 +784,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p 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; } } @@ -788,8 +792,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p ma = ma->next; } } - if(pts != NULL) - g_list_free(pts); + g_list_free(pts); ml = ml->next; } return -1;