BAT decoding fix

[email protected] (Roberto Corno)
Newsgroups gmane.comp.video.videolan.libdvbpsi.devel
Message-ID <[email protected]>
libdvbpsi | branch: master | Roberto Corno <[email protected]> | Thu Aug  9 12:27:24 2012 +0200| [5175238f1118b83f35ba93be8e2cac4bd2e6f21f] | committer: Jean-Paul Saman

BAT decoding fix

The dvbpsi_bat_sections_decode method parsing index was wrongly incremented
dvbpsi_AddSectionBAT method did not correctly check for memory allocation.

Signed-off-by: Jean-Paul Saman <[email protected]>

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=5175238f1118b83f35ba93be8e2cac4bd2e6f21f
---

 src/tables/bat.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/tables/bat.c b/src/tables/bat.c
index a3e2806..4dec6a6 100644
--- a/src/tables/bat.c
+++ b/src/tables/bat.c
@@ -339,7 +339,7 @@ static bool dvbpsi_AddSectionBAT(dvbpsi_t *p_dvbpsi, dvbpsi_bat_decoder_t *p_bat
     {
         p_bat_decoder->p_building_bat = dvbpsi_bat_new(p_section->i_extension,
                               p_section->i_version, p_section->b_current_next);
-        if (p_bat_decoder->p_building_bat)
+        if (!p_bat_decoder->p_building_bat)
             return false;
 
         p_bat_decoder->i_last_section_number = p_section->i_last_number;
@@ -492,11 +492,12 @@ void dvbpsi_bat_sections_decode(dvbpsi_bat_t* p_bat,
     {
         p_end = p_section->p_payload_end;
     }
-    p_byte += 2;
 
     /* - TSs */
     for(; p_byte + 6 <= p_end;)
     {
+      p_byte += 2;
+
       uint16_t i_ts_id = ((uint16_t)p_byte[0] << 8) | p_byte[1];
       uint16_t i_orig_network_id = ((uint16_t)p_byte[2] << 8) | p_byte[3];
       uint16_t i_transport_descriptors_length = ((uint16_t)(p_byte[4] & 0x0f) << 8) | p_byte[5];

_______________________________________________
libdvbpsi-devel mailing list
[email protected]
http://mailman.videolan.org/listinfo/libdvbpsi-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.