Skip to content

Commit

Permalink
[MqttSrc] fix leak case
Browse files Browse the repository at this point in the history
Code clean, caps_replace() function increases ref count of new caps.
Fix mem leak case when using caps_replace().

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung committed Nov 11, 2024
1 parent c3e16b9 commit 0fb903c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions gst/mqtt/mqttsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ cb_mqtt_on_message_arrived (void *context, char *topic_name, int topic_len,
GstBaseSrc *basesrc;
GstMqttSrc *self;
GstClock *clock;
GstCaps *recv_caps;
gsize offset;
guint i;
UNUSED (topic_name);
Expand Down Expand Up @@ -1135,18 +1136,14 @@ cb_mqtt_on_message_arrived (void *context, char *topic_name, int topic_len,
goto ret_unref_received_mem;
}

if (!self->caps) {
self->caps = gst_caps_from_string (mqtt_msg_hdr->gst_caps_str);
gst_mqtt_src_renegotiate (basesrc);
} else {
GstCaps *recv_caps = gst_caps_from_string (mqtt_msg_hdr->gst_caps_str);

if (recv_caps && !gst_caps_is_equal (self->caps, recv_caps)) {
recv_caps = gst_caps_from_string (mqtt_msg_hdr->gst_caps_str);
if (recv_caps) {
if (!self->caps || !gst_caps_is_equal (self->caps, recv_caps)) {
gst_caps_replace (&self->caps, recv_caps);
gst_mqtt_src_renegotiate (basesrc);
} else {
gst_caps_replace (&recv_caps, NULL);
}

gst_caps_unref (recv_caps);
}

buffer = gst_buffer_new ();
Expand Down

0 comments on commit 0fb903c

Please sign in to comment.