CCExtractor / CCExtractor/ccextractor

[BUG]: Last EIT section never parsed — EPG_free() discards pending epg_buffers without flushing

オープン
#2,165 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C
スター
903
フォーク
589
平均マージ
3日 2時間
マージ済み PR(30日)
10

説明

## Summary

In `src/lib_ccx/ts_tables_epg.c`, the last EIT section in any stream is silently
discarded because `EPG_free()` frees `epg_buffers` without first flushing
accumulated data.

## Root Cause

`parse_EPG_packet()` accumulates TS packets into `epg_buffers[]` and only calls
`EPG_parse_table()` when a new section starts (`payload_start_indicator=1`).
This means the **last accumulated section is never parsed** — there is no
following packet to trigger the flush.

`EPG_free()` then frees the buffers without processing them:
```c
void EPG_free(struct lib_ccx_ctx *ctx)
{
// ... output logic ...
free(ctx->epg_buffers); // ← pending data discarded here!
free(ctx->eit_programs);
}
```

## Impact

- The last EIT table section in every stream is lost
- For short streams or streams with few EIT sections, this can mean entire
programs are missing from XMLTV output
- There is a related `XXX hack` comment in `EPG_DVB_decode_EIT()` at line 1420
that was added to prevent a segfault caused by this same issue

## Fix

In `EPG_free()`, before freeing, iterate over all `epg_buffers` slots and
flush any with `ccounter > 0`:
```c
// Flush any pending EIT sections before freeing
for (int i = 0; i <= 0xfff; i++) {
if (ctx->epg_buffers[i].buffer != NULL && ctx->epg_buffers[i].ccounter > 0) {
EPG_parse_table(ctx, ctx->epg_buffers[i].buffer,
ctx->epg_buffers[i].buffer_length);
free(ctx->epg_buffers[i].buffer);
ctx->epg_buffers[i].buffer = NULL;
}
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。