@@ -1383,6 +1383,11 @@ int st_app_parse_json(st_json_context_t* ctx, const char* filename) {
13831383 int num_interfaces = json_object_array_length (interfaces_array );
13841384 ctx -> interfaces =
13851385 (st_json_interface_t * )st_app_zmalloc (num_interfaces * sizeof (st_json_interface_t ));
1386+ if (!ctx -> interfaces ) {
1387+ err ("%s, failed to allocate interfaces\n" , __func__ );
1388+ ret = - ST_JSON_NULL ;
1389+ goto error ;
1390+ }
13861391 for (int i = 0 ; i < num_interfaces ; ++ i ) {
13871392 ret = st_json_parse_interfaces (json_object_array_get_idx (interfaces_array , i ),
13881393 & ctx -> interfaces [i ]);
@@ -1427,14 +1432,39 @@ int st_app_parse_json(st_json_context_t* ctx, const char* filename) {
14271432 /* allocate tx sessions */
14281433 ctx -> tx_video_sessions = (st_json_video_session_t * )st_app_zmalloc (
14291434 ctx -> tx_video_session_cnt * sizeof (st_json_video_session_t ));
1435+ if (!ctx -> tx_video_sessions ) {
1436+ err ("%s, failed to allocate tx_video_sessions\n" , __func__ );
1437+ ret = - ST_JSON_NULL ;
1438+ goto error ;
1439+ }
14301440 ctx -> tx_audio_sessions = (st_json_audio_session_t * )st_app_zmalloc (
14311441 ctx -> tx_audio_session_cnt * sizeof (st_json_audio_session_t ));
1442+ if (!ctx -> tx_audio_sessions ) {
1443+ err ("%s, failed to allocate tx_audio_sessions\n" , __func__ );
1444+ ret = - ST_JSON_NULL ;
1445+ goto error ;
1446+ }
14321447 ctx -> tx_anc_sessions = (st_json_ancillary_session_t * )st_app_zmalloc (
14331448 ctx -> tx_anc_session_cnt * sizeof (st_json_ancillary_session_t ));
1449+ if (!ctx -> tx_anc_sessions ) {
1450+ err ("%s, failed to allocate tx_anc_sessions\n" , __func__ );
1451+ ret = - ST_JSON_NULL ;
1452+ goto error ;
1453+ }
14341454 ctx -> tx_st22p_sessions = (st_json_st22p_session_t * )st_app_zmalloc (
14351455 ctx -> tx_st22p_session_cnt * sizeof (st_json_st22p_session_t ));
1456+ if (!ctx -> tx_st22p_sessions ) {
1457+ err ("%s, failed to allocate tx_st22p_sessions\n" , __func__ );
1458+ ret = - ST_JSON_NULL ;
1459+ goto error ;
1460+ }
14361461 ctx -> tx_st20p_sessions = (st_json_st20p_session_t * )st_app_zmalloc (
14371462 ctx -> tx_st20p_session_cnt * sizeof (st_json_st20p_session_t ));
1463+ if (!ctx -> tx_st20p_sessions ) {
1464+ err ("%s, failed to allocate tx_st20p_sessions\n" , __func__ );
1465+ ret = - ST_JSON_NULL ;
1466+ goto error ;
1467+ }
14381468
14391469 int num_inf = 0 ;
14401470 int num_video = 0 ;
@@ -1692,14 +1722,39 @@ int st_app_parse_json(st_json_context_t* ctx, const char* filename) {
16921722 /* allocate tx sessions */
16931723 ctx -> rx_video_sessions = (st_json_video_session_t * )st_app_zmalloc (
16941724 ctx -> rx_video_session_cnt * sizeof (st_json_video_session_t ));
1725+ if (!ctx -> rx_video_sessions ) {
1726+ err ("%s, failed to allocate rx_video_sessions\n" , __func__ );
1727+ ret = - ST_JSON_NULL ;
1728+ goto error ;
1729+ }
16951730 ctx -> rx_audio_sessions = (st_json_audio_session_t * )st_app_zmalloc (
16961731 ctx -> rx_audio_session_cnt * sizeof (st_json_audio_session_t ));
1732+ if (!ctx -> rx_audio_sessions ) {
1733+ err ("%s, failed to allocate rx_audio_sessions\n" , __func__ );
1734+ ret = - ST_JSON_NULL ;
1735+ goto error ;
1736+ }
16971737 ctx -> rx_anc_sessions = (st_json_ancillary_session_t * )st_app_zmalloc (
16981738 ctx -> rx_anc_session_cnt * sizeof (st_json_ancillary_session_t ));
1739+ if (!ctx -> rx_anc_sessions ) {
1740+ err ("%s, failed to allocate rx_anc_sessions\n" , __func__ );
1741+ ret = - ST_JSON_NULL ;
1742+ goto error ;
1743+ }
16991744 ctx -> rx_st22p_sessions = (st_json_st22p_session_t * )st_app_zmalloc (
17001745 ctx -> rx_st22p_session_cnt * sizeof (st_json_st22p_session_t ));
1746+ if (!ctx -> rx_st22p_sessions ) {
1747+ err ("%s, failed to allocate rx_st22p_sessions\n" , __func__ );
1748+ ret = - ST_JSON_NULL ;
1749+ goto error ;
1750+ }
17011751 ctx -> rx_st20p_sessions = (st_json_st20p_session_t * )st_app_zmalloc (
17021752 ctx -> rx_st20p_session_cnt * sizeof (st_json_st20p_session_t ));
1753+ if (!ctx -> rx_st20p_sessions ) {
1754+ err ("%s, failed to allocate rx_st20p_sessions\n" , __func__ );
1755+ ret = - ST_JSON_NULL ;
1756+ goto error ;
1757+ }
17031758
17041759 int num_inf = 0 ;
17051760 int num_video = 0 ;
0 commit comments