Browse Source

nit_desc: Prevent memory leak on error path.

Georgi Chorbadzhiyski 5 years ago
parent
commit
91b13d75b8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      nit_desc.c

+ 2 - 3
nit_desc.c View File

@@ -225,6 +225,8 @@ int ts_nit_add_lcn_descriptor(struct ts_nit *nit, uint16_t ts_id, uint16_t org_n
225 225
 
226 226
 
227 227
 int ts_nit_add_stream_descriptors(struct ts_nit *nit, uint16_t ts_id, uint16_t org_net_id, uint32_t freq, uint8_t modulation, uint32_t symbol_rate, uint32_t *lcn_services, uint32_t *svc_services, uint8_t num_services) {
228
+	if (!num_services || num_services > 85) // 85 * 3 == 255
229
+		return 0;
228 230
 	
229 231
 	int desc_size = 13 + 6 + 2 + 2 + num_services * 4 + num_services * 3;		// 2 for header desc header, + ....
230 232
 	
@@ -246,9 +248,6 @@ int ts_nit_add_stream_descriptors(struct ts_nit *nit, uint16_t ts_id, uint16_t o
246 248
 	desc[12] |= 0;									// 4 bits FEC_inner (0 == not defined)
247 249
 
248 250
 	uint8_t i;
249
-	if (!num_services || num_services > 85) // 85 * 3 == 255
250
-		return 0;
251
-	
252 251
 	int desc_svc_size = 2 + num_services * 3;		// 2 for header desc header, 3 for each service
253 252
 	
254 253