mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
tsmux: Fix error handling in pad_stream
Don't leak the map or the buffer if we encounter an error. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5490>
This commit is contained in:
parent
b1810d83bc
commit
8a7d0efd96
1 changed files with 15 additions and 6 deletions
|
@ -1546,18 +1546,25 @@ pad_stream (TsMux * mux, TsMuxStream * stream, gint64 cur_ts)
|
|||
goto done;
|
||||
}
|
||||
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
if (!gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
|
||||
gst_buffer_unref (buf);
|
||||
ret = FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
memset (map.data, 0xFF, map.size);
|
||||
|
||||
if ((new_pcr =
|
||||
write_new_pcr (mux, stream, get_current_pcr (mux,
|
||||
cur_ts), get_next_pcr (mux, cur_ts)) != -1)) {
|
||||
new_pcr = write_new_pcr (mux, stream, get_current_pcr (mux, cur_ts),
|
||||
get_next_pcr (mux, cur_ts));
|
||||
if (new_pcr != -1) {
|
||||
GST_LOG ("Writing PCR-only packet on PID 0x%04x", stream->pi.pid);
|
||||
tsmux_write_ts_header (mux, map.data, &stream->pi, &payload_len,
|
||||
&payload_offs, 0);
|
||||
} else {
|
||||
GST_LOG ("Writing null stuffing packet");
|
||||
if (!rewrite_si (mux, cur_ts)) {
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
ret = FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
@ -1567,9 +1574,11 @@ pad_stream (TsMux * mux, TsMuxStream * stream, gint64 cur_ts)
|
|||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
stream->pi.flags &= TSMUX_PACKET_FLAG_PES_FULL_HEADER;
|
||||
|
||||
if (!(ret = tsmux_packet_out (mux, buf, new_pcr)))
|
||||
ret = tsmux_packet_out (mux, buf, new_pcr);
|
||||
if (!ret) {
|
||||
gst_buffer_unref (buf);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
} while (bitrate < mux->bitrate);
|
||||
|
||||
|
|
Loading…
Reference in a new issue