Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libdvbpsi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
libdvbpsi
Commits
c080a8a7
Commit
c080a8a7
authored
Feb 14, 2011
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tables and descriptors: check malloc return value.
Check mallocs return value.
parent
a39ac177
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
57 deletions
+71
-57
src/descriptor.c
src/descriptor.c
+25
-29
src/descriptors/dr_02.c
src/descriptors/dr_02.c
+1
-4
src/tables/bat.c
src/tables/bat.c
+8
-4
src/tables/cat.c
src/tables/cat.c
+5
-3
src/tables/nit.c
src/tables/nit.c
+7
-4
src/tables/pat.c
src/tables/pat.c
+8
-4
src/tables/pmt.c
src/tables/pmt.c
+9
-6
src/tables/sis.c
src/tables/sis.c
+4
-2
src/tables/tot.c
src/tables/tot.c
+4
-1
No files found.
src/descriptor.c
View file @
c080a8a7
/*****************************************************************************
* descriptor.c: descriptors functions
*----------------------------------------------------------------------------
* Copyright (C) 2001-201
0
VideoLAN
* Copyright (C) 2001-201
1
VideoLAN
* $Id: descriptor.c,v 1.6 2002/10/07 14:15:14 sam Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
...
...
@@ -24,7 +24,6 @@
*
*****************************************************************************/
#include "config.h"
#include <stdlib.h>
...
...
@@ -48,33 +47,31 @@
dvbpsi_descriptor_t
*
dvbpsi_NewDescriptor
(
uint8_t
i_tag
,
uint8_t
i_length
,
uint8_t
*
p_data
)
{
dvbpsi_descriptor_t
*
p_descriptor
dvbpsi_descriptor_t
*
p_descriptor
=
(
dvbpsi_descriptor_t
*
)
malloc
(
sizeof
(
dvbpsi_descriptor_t
));
if
(
p_descriptor
)
{
p_descriptor
->
p_data
=
(
uint8_t
*
)
malloc
(
i_length
*
sizeof
(
uint8_t
));
if
(
p_descriptor
==
NULL
)
return
NULL
;
if
(
p_descriptor
->
p_data
)
p_descriptor
->
p_data
=
(
uint8_t
*
)
malloc
(
i_length
*
sizeof
(
uint8_t
));
if
(
p_descriptor
->
p_data
)
{
p_descriptor
->
i_tag
=
i_tag
;
p_descriptor
->
i_length
=
i_length
;
if
(
p_data
)
memcpy
(
p_descriptor
->
p_data
,
p_data
,
i_length
);
p_descriptor
->
p_decoded
=
NULL
;
p_descriptor
->
p_next
=
NULL
;
p_descriptor
->
i_tag
=
i_tag
;
p_descriptor
->
i_length
=
i_length
;
if
(
p_data
)
memcpy
(
p_descriptor
->
p_data
,
p_data
,
i_length
);
p_descriptor
->
p_decoded
=
NULL
;
p_descriptor
->
p_next
=
NULL
;
}
else
{
free
(
p_descriptor
);
p_descriptor
=
NULL
;
free
(
p_descriptor
);
p_descriptor
=
NULL
;
}
}
return
p_descriptor
;
return
p_descriptor
;
}
/*****************************************************************************
* dvbpsi_DeleteDescriptors
*****************************************************************************
...
...
@@ -82,18 +79,17 @@ dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length,
*****************************************************************************/
void
dvbpsi_DeleteDescriptors
(
dvbpsi_descriptor_t
*
p_descriptor
)
{
while
(
p_descriptor
!=
NULL
)
{
dvbpsi_descriptor_t
*
p_next
=
p_descriptor
->
p_next
;
while
(
p_descriptor
!=
NULL
)
{
dvbpsi_descriptor_t
*
p_next
=
p_descriptor
->
p_next
;
if
(
p_descriptor
->
p_data
!=
NULL
)
free
(
p_descriptor
->
p_data
);
if
(
p_descriptor
->
p_data
!=
NULL
)
free
(
p_descriptor
->
p_data
);
if
(
p_descriptor
->
p_decoded
!=
NULL
)
free
(
p_descriptor
->
p_decoded
);
if
(
p_descriptor
->
p_decoded
!=
NULL
)
free
(
p_descriptor
->
p_decoded
);
free
(
p_descriptor
);
p_descriptor
=
p_next
;
}
free
(
p_descriptor
);
p_descriptor
=
p_next
;
}
}
src/descriptors/dr_02.c
View file @
c080a8a7
/*****************************************************************************
* dr_02.c
* Copyright (C) 2001-201
0
VideoLAN
* Copyright (C) 2001-201
1
VideoLAN
* $Id: dr_02.c,v 1.7 2003/07/25 20:20:40 fenrir Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
...
...
@@ -21,7 +21,6 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
...
...
@@ -40,7 +39,6 @@
#include "dr_02.h"
/*****************************************************************************
* dvbpsi_DecodeVStreamDr
*****************************************************************************/
...
...
@@ -62,7 +60,6 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Decode data and check the length */
p_decoded
->
b_mpeg2
=
(
p_descriptor
->
p_data
[
0
]
&
0x04
)
?
1
:
0
;
if
(
(
!
p_decoded
->
b_mpeg2
&&
(
p_descriptor
->
i_length
!=
1
))
||
(
p_decoded
->
b_mpeg2
&&
(
p_descriptor
->
i_length
!=
3
)))
{
...
...
src/tables/bat.c
View file @
c080a8a7
...
...
@@ -401,10 +401,14 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
{
p_bat_decoder
->
p_building_bat
=
(
dvbpsi_bat_t
*
)
malloc
(
sizeof
(
dvbpsi_bat_t
));
dvbpsi_InitBAT
(
p_bat_decoder
->
p_building_bat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_bat_decoder
->
p_building_bat
)
dvbpsi_InitBAT
(
p_bat_decoder
->
p_building_bat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"BAT decoder"
,
"failed decoding BAT section"
);
p_bat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
...
...
src/tables/cat.c
View file @
c080a8a7
...
...
@@ -280,9 +280,11 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
{
p_cat_decoder
->
p_building_cat
=
(
dvbpsi_cat_t
*
)
malloc
(
sizeof
(
dvbpsi_cat_t
));
dvbpsi_InitCAT
(
p_cat_decoder
->
p_building_cat
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_cat_decoder
->
p_building_cat
)
dvbpsi_InitCAT
(
p_cat_decoder
->
p_building_cat
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"CAT decoder"
,
"failed decoding section"
);
p_cat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
...
...
src/tables/nit.c
View file @
c080a8a7
...
...
@@ -392,10 +392,13 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
if
(
!
p_nit_decoder
->
p_building_nit
)
{
p_nit_decoder
->
p_building_nit
=
(
dvbpsi_nit_t
*
)
malloc
(
sizeof
(
dvbpsi_nit_t
));
dvbpsi_InitNIT
(
p_nit_decoder
->
p_building_nit
,
p_nit_decoder
->
i_network_id
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_nit_decoder
->
p_building_nit
)
dvbpsi_InitNIT
(
p_nit_decoder
->
p_building_nit
,
p_nit_decoder
->
i_network_id
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_debug
(
p_dvbpsi
,
"NIT decoder"
,
"failed decoding section"
);
p_nit_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
...
...
src/tables/pat.c
View file @
c080a8a7
...
...
@@ -304,10 +304,14 @@ void dvbpsi_GatherPATSections(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sectio
{
p_pat_decoder
->
p_building_pat
=
(
dvbpsi_pat_t
*
)
malloc
(
sizeof
(
dvbpsi_pat_t
));
dvbpsi_InitPAT
(
p_pat_decoder
->
p_building_pat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
if
(
p_pat_decoder
->
p_building_pat
)
dvbpsi_InitPAT
(
p_pat_decoder
->
p_building_pat
,
p_section
->
i_extension
,
p_section
->
i_version
,
p_section
->
b_current_next
);
else
dvbpsi_error
(
p_dvbpsi
,
"PAT decoder"
,
"failed decoding section"
);
p_pat_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
...
...
src/tables/pmt.c
View file @
c080a8a7
...
...
@@ -361,12 +361,15 @@ void dvbpsi_GatherPMTSections(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t* p_sectio
{
p_pmt_decoder
->
p_building_pmt
=
(
dvbpsi_pmt_t
*
)
malloc
(
sizeof
(
dvbpsi_pmt_t
));
dvbpsi_InitPMT
(
p_pmt_decoder
->
p_building_pmt
,
p_pmt_decoder
->
i_program_number
,
p_section
->
i_version
,
p_section
->
b_current_next
,
((
uint16_t
)(
p_section
->
p_payload_start
[
0
]
&
0x1f
)
<<
8
)
|
p_section
->
p_payload_start
[
1
]);
if
(
p_pmt_decoder
->
p_building_pmt
)
dvbpsi_InitPMT
(
p_pmt_decoder
->
p_building_pmt
,
p_pmt_decoder
->
i_program_number
,
p_section
->
i_version
,
p_section
->
b_current_next
,
((
uint16_t
)(
p_section
->
p_payload_start
[
0
]
&
0x1f
)
<<
8
)
|
p_section
->
p_payload_start
[
1
]);
else
dvbpsi_debug
(
p_dvbpsi
,
"PMT decoder"
,
"failed decoding section"
);
p_pmt_decoder
->
i_last_section_number
=
p_section
->
i_last_number
;
}
...
...
src/tables/sis.c
View file @
c080a8a7
...
...
@@ -321,8 +321,10 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
{
p_sis_decoder
->
p_building_sis
=
(
dvbpsi_sis_t
*
)
malloc
(
sizeof
(
dvbpsi_sis_t
));
// FIXME: potiential crash on OUT OF MEMORY
dvbpsi_InitSIS
(
p_sis_decoder
->
p_building_sis
,
0
);
if
(
p_sis_decoder
->
p_building_sis
)
dvbpsi_InitSIS
(
p_sis_decoder
->
p_building_sis
,
0
);
else
dvbpsi_error
(
p_dvbpsi
,
"SIS decoder"
,
"failed decoding section"
);
}
}
else
...
...
src/tables/tot.c
View file @
c080a8a7
...
...
@@ -234,11 +234,14 @@ void dvbpsi_GatherTOTSections(dvbpsi_t* p_dvbpsi,
}
p_building_tot
=
(
dvbpsi_tot_t
*
)
malloc
(
sizeof
(
dvbpsi_tot_t
));
dvbpsi_InitTOT
(
p_building_tot
,
((
uint64_t
)
p_section
->
p_payload_start
[
0
]
<<
32
)
if
(
p_building_tot
)
dvbpsi_InitTOT
(
p_building_tot
,
((
uint64_t
)
p_section
->
p_payload_start
[
0
]
<<
32
)
|
((
uint64_t
)
p_section
->
p_payload_start
[
1
]
<<
24
)
|
((
uint64_t
)
p_section
->
p_payload_start
[
2
]
<<
16
)
|
((
uint64_t
)
p_section
->
p_payload_start
[
3
]
<<
8
)
|
(
uint64_t
)
p_section
->
p_payload_start
[
4
]);
else
dvbpsi_error
(
p_dvbpsi
,
"TOT decoder"
,
"failed decoding section"
);
/* Decode the section */
dvbpsi_DecodeTOTSections
(
p_dvbpsi
,
p_building_tot
,
p_section
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment