Browse Source

cat: Check malloc result.

Georgi Chorbadzhiyski 6 years ago
parent
commit
78c50ec87b
1 changed files with 4 additions and 0 deletions
  1. 4 0
      cat.c

+ 4 - 0
cat.c View File

@@ -93,10 +93,14 @@ int ts_cat_parse(struct ts_cat *cat) {
93 93
 	uint8_t *section_data = cat->section_header->data;
94 94
 	int section_len = cat->section_header->data_len;
95 95
 
96
+	if (section_len > 4096)
97
+		return 0;
96 98
 	/* Handle streams */
97 99
 	uint8_t *stream_data = section_data;
98 100
 	cat->program_info_size = section_len;
99 101
 	cat->program_info = malloc(cat->program_info_size);
102
+	if (!cat->program_info)
103
+		return 0;
100 104
 	memcpy(cat->program_info, stream_data, cat->program_info_size);
101 105
 	stream_data += cat->program_info_size;
102 106