[libdvdnav-devel] [PATCH 23/33] Use calloc as a safety measure since ifoRead functions populate parts of the data independently

beandog at gentoo.org beandog at gentoo.org
Thu Jan 15 21:45:35 CET 2015


From: Steve Dibb <steve.dibb at gmail.com>

---
 src/ifo_read.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ifo_read.c b/src/ifo_read.c
index 5286340..9cc03d8 100644
--- a/src/ifo_read.c
+++ b/src/ifo_read.c
@@ -830,7 +830,7 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile,
 
   if(cmd_tbl->nr_of_pre > 0) {
     unsigned int pre_cmds_size  = cmd_tbl->nr_of_pre * COMMAND_DATA_SIZE;
-    cmd_tbl->pre_cmds = malloc(pre_cmds_size);
+    cmd_tbl->pre_cmds = calloc(1, pre_cmds_size);
     if(!cmd_tbl->pre_cmds)
       return 0;
 
@@ -843,7 +843,7 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile,
 
   if(cmd_tbl->nr_of_post > 0) {
     unsigned int post_cmds_size = cmd_tbl->nr_of_post * COMMAND_DATA_SIZE;
-    cmd_tbl->post_cmds = malloc(post_cmds_size);
+    cmd_tbl->post_cmds = calloc(1, post_cmds_size);
     if(!cmd_tbl->post_cmds) {
       free(cmd_tbl->pre_cmds);
       cmd_tbl->pre_cmds = NULL;
@@ -860,7 +860,7 @@ static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile,
 
   if(cmd_tbl->nr_of_cell > 0) {
     unsigned int cell_cmds_size = cmd_tbl->nr_of_cell * COMMAND_DATA_SIZE;
-    cmd_tbl->cell_cmds = malloc(cell_cmds_size);
+    cmd_tbl->cell_cmds = calloc(1, cell_cmds_size);
     if(!cmd_tbl->cell_cmds) {
       free(cmd_tbl->pre_cmds);
       cmd_tbl->pre_cmds = NULL;
-- 
2.0.4



More information about the libdvdnav-devel mailing list