Repository navigation
Description
Found while reading the caption path for the caption text port (#1617, #1618); no upstream report. OBS master (95d5223b6) has the same code in libobs/obs-output.c (da_init(out_data) at line 1561, return avc || hevc || av1; at line 1678), so this fork inherited it.
Location
libobs/obs-output.c.h, add_caption() (line 1519). This is still C: the interleaver port (#1603) calls it through obs_output_interleave_add_caption(), and the caption text port (#1618) moved only the page wrap. No Rust or oracle copy of it exists.
- Lines 1581-1583 build the new packet in
out_data(alongreference count, then the whole packet's data) before the codec is checked. - The caption is then taken off the queue whatever the codec: a text page is unlinked and freed (1630-1633), or the whole CEA-708 queue is drained (1591-1621). The comment at 1529-1532 says that is on purpose, so the queue still drains on codecs that cannot carry captions.
- Only the
if (avc || hevc || av1)branch (1636) handsout_dataon, as the new packet's data. For any other codec, the function reachesreturn avc || hevc || av1;(1698) without_datastill allocated and nothing pointing at it.
Class
Memory leak, bounded by the captions. One packet-sized buffer (the video packet plus 8 bytes) per caption page, and per CEA-708 batch (one per frame while caption data keeps arriving). No crash, no wrong output: the packet itself is unchanged and the caption is dropped, as intended.
Not reachable from untrusted input in what OBS ships. Every caller in the tree sends captions to the streaming output (the Captions tool in frontend-tools, obs-websocket SendStreamCaption, decklink-captions), and the streaming outputs accept only h264, hevc and av1 (RTMP, WHIP, the MPEG-TS muxer for SRT/RIST). It is reached by a plugin or script that calls obs_output_output_caption_text1/2() or obs_output_caption() on another output, for example a MOV recording with ProRes (mp4-output lists h264;hevc;prores), or on an output with a plugin's own codec.
Reproduced on master
A real AV output through the public API (test_output_caption_codec, headless: private Xvfb): a registered video encoder that reports prores, one that reports h264 as a control, and one audio encoder, fed by hand. A capture queues captions, sends 12 frames, stops, and compares bnum_allocs() with the count before it (after a warm-up capture).
| Build | Codec | Captions | Allocations left after the capture |
|---|---|---|---|
| master 8c59b2c, libobs (C backend), hybrid libobs, libobs-c-reference | prores | 3 text pages | 3 |
| the same | prores | one CEA-708 batch | 1 |
| the same | prores | none | 0 |
| the same | h264 | 3 text pages, one CEA-708 batch | 0 (the captions reach the packets) |
Fix
Build out_data inside the if (avc || hevc || av1) branch, where it replaces the packet. For any other codec nothing is allocated, the packet stays as it is, and the caption is still taken off the queue, as before. No behaviour change. PR follows.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 22, 2026
Claiming: #1777. Test and fix are ready; PR follows.
libobs: Copy the packet in add_caption() only for codecs with captions
libobs: Copy the packet in add_caption() only for codecs with captions (