Commit 476a525a authored by Jean-Paul Saman's avatar Jean-Paul Saman

Dereference after NULL check (Fixes CID #134926, #134927, #134928, #13429,...

Dereference after NULL check (Fixes CID #134926, #134927, #134928, #13429, #13430, #134931, #134932, #134933, #134934, #134935, #134936, #134937, #134938, #134939, #134940)

Check the dvbpsi handle before passing it to dvbpsi_chain_demux_delete().
parent 1647815b
...@@ -2499,19 +2499,19 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data) ...@@ -2499,19 +2499,19 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
return stream; return stream;
error: error:
if (!dvbpsi_chain_demux_delete(stream->pat.handle)) if (stream->pat.handle && !dvbpsi_chain_demux_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->cat.handle)) if (stream->cat.handle && !dvbpsi_chain_demux_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->sdt.handle)) if (stream->sdt.handle && !dvbpsi_chain_demux_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->eit.handle)) if (stream->eit.handle && !dvbpsi_chain_demux_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->rst.handle)) if (stream->rst.handle && !dvbpsi_chain_demux_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->tdt.handle)) if (stream->tdt.handle && !dvbpsi_chain_demux_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->atsc.handle)) if (stream->atsc.handle && !dvbpsi_chain_demux_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle) if (stream->pat.handle)
...@@ -2538,7 +2538,7 @@ void libdvbpsi_exit(ts_stream_t *stream) ...@@ -2538,7 +2538,7 @@ void libdvbpsi_exit(ts_stream_t *stream)
{ {
summary(stdout, stream); summary(stdout, stream);
if (!dvbpsi_chain_demux_delete(stream->pat.handle)) if (stream->pat.handle && !dvbpsi_chain_demux_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
ts_pmt_t *p_pmt = stream->pmt; ts_pmt_t *p_pmt = stream->pmt;
...@@ -2574,17 +2574,17 @@ void libdvbpsi_exit(ts_stream_t *stream) ...@@ -2574,17 +2574,17 @@ void libdvbpsi_exit(ts_stream_t *stream)
free(p_atsc_prev); free(p_atsc_prev);
} }
if (!dvbpsi_chain_demux_delete(stream->cat.handle)) if (stream->cat.handle && !dvbpsi_chain_demux_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->sdt.handle)) if (stream->sdt.handle && !dvbpsi_chain_demux_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->eit.handle)) if (stream->eit.handle && !dvbpsi_chain_demux_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->rst.handle)) if (stream->rst.handle && !dvbpsi_chain_demux_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->tdt.handle)) if (stream->tdt.handle && !dvbpsi_chain_demux_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_chain_demux_delete(stream->atsc.handle)) if (stream->atsc.handle && !dvbpsi_chain_demux_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n"); fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle) if (stream->pat.handle)
......
...@@ -109,6 +109,8 @@ bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new, ...@@ -109,6 +109,8 @@ bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
*****************************************************************************/ *****************************************************************************/
bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi) bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi)
{ {
if (!p_dvbpsi) return false;
dvbpsi_decoder_t *p_demux = p_dvbpsi->p_decoder; dvbpsi_decoder_t *p_demux = p_dvbpsi->p_decoder;
if (!p_demux) return false; if (!p_demux) return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment