Skip to content

Commit 5ca59eb

Browse files
Rahul-2k4claude
andcommitted
fix(dvb-split): prevent Rust panic during DVB subtitle pipeline cleanup
When processing DVB streams with --split-dvb-subs, split pipelines can have timing contexts where current_pts < min_pts even when pts_set >= 2. This causes integer overflow in the Rust timing code when calculating fts_now. Fixes: - Add PTS validation before get_fts() in regular decoder cleanup - Remove unsafe get_fts() call in split DVB pipeline cleanup, use fallback timing Tested on tnt-uhf30-546MHz.ts (previously crashed) and 6 other samples. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 39646da commit 5ca59eb

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/lib_ccx/lib_ccx.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ void dinit_libraries(struct lib_ccx_ctx **ctx)
290290
}
291291

292292
flush_cc_decode(dec_ctx, &dec_ctx->dec_sub);
293-
cfts = get_fts(dec_ctx->timing, dec_ctx->current_field);
293+
if (dec_ctx->timing && dec_ctx->timing->pts_set >= 2 &&
294+
dec_ctx->timing->current_pts >= dec_ctx->timing->min_pts)
295+
cfts = get_fts(dec_ctx->timing, dec_ctx->current_field);
294296
enc_ctx = get_encoder_by_pn(lctx, dec_ctx->program_number);
295297
if (enc_ctx && dec_ctx->dec_sub.got_output == CCX_TRUE)
296298
{
@@ -319,21 +321,11 @@ void dinit_libraries(struct lib_ccx_ctx **ctx)
319321
// Check if there's a pending subtitle in the prev buffer
320322
if (p->dec_ctx->dec_sub.prev && p->dec_ctx->dec_sub.prev->data && p->encoder->prev)
321323
{
322-
// Calculate end time for the last subtitle
323-
LLONG current_fts = 0;
324-
if (p->dec_ctx->timing)
325-
{
326-
current_fts = get_fts(p->dec_ctx->timing, p->dec_ctx->current_field);
327-
}
328-
329-
// Force end time if missing
324+
// Force end time if missing - use 2 second fallback
325+
// Note: We skip get_fts() here because split DVB pipelines may have
326+
// timing contexts in invalid states that cause Rust overflow panics
330327
if (p->dec_ctx->dec_sub.prev->end_time == 0)
331-
{
332-
if (current_fts > p->dec_ctx->dec_sub.prev->start_time)
333-
p->dec_ctx->dec_sub.prev->end_time = current_fts;
334-
else
335-
p->dec_ctx->dec_sub.prev->end_time = p->dec_ctx->dec_sub.prev->start_time + 2000; // 2s fallback
336-
}
328+
p->dec_ctx->dec_sub.prev->end_time = p->dec_ctx->dec_sub.prev->start_time + 2000;
337329

338330
encode_sub(p->encoder->prev, p->dec_ctx->dec_sub.prev);
339331
}

0 commit comments

Comments
 (0)