@@ -300,6 +300,9 @@ ngx_rtmp_live_merge_app_conf(ngx_conf_t *cf, void *parent, void *child)
300
300
301
301
conf -> streams = ngx_pcalloc (cf -> pool ,
302
302
sizeof (ngx_rtmp_live_stream_t * ) * conf -> nbuckets );
303
+ if (conf -> streams == NULL ) {
304
+ return NGX_CONF_ERROR ;
305
+ }
303
306
304
307
return NGX_CONF_OK ;
305
308
}
@@ -360,6 +363,11 @@ ngx_rtmp_live_get_stream(ngx_rtmp_session_t *s, u_char *name, int create)
360
363
lacf -> free_streams = lacf -> free_streams -> next ;
361
364
} else {
362
365
* stream = ngx_palloc (lacf -> pool , sizeof (ngx_rtmp_live_stream_t ));
366
+ if (* stream == NULL ) {
367
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
368
+ "live: failed to allocate for stream" );
369
+ return NULL ;
370
+ }
363
371
}
364
372
ngx_memzero (* stream , sizeof (ngx_rtmp_live_stream_t ));
365
373
ngx_memcpy ((* stream )-> name , name ,
@@ -624,8 +632,22 @@ ngx_rtmp_live_join(ngx_rtmp_session_t *s, u_char *name, unsigned publisher)
624
632
if (ctx == NULL ) {
625
633
ctx = ngx_palloc (s -> connection -> pool , sizeof (ngx_rtmp_live_ctx_t ));
626
634
if (ctx == NULL ) {
627
- ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
628
- "live: failed to allocate for ctx" );
635
+ if (publisher ) {
636
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
637
+ "live: failed to allocate for publish ctx" );
638
+
639
+ ngx_rtmp_send_status (s , "NetStream.Publish.Failed" , "error" ,
640
+ "Failed to allocate memory" );
641
+ } else {
642
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
643
+ "live: failed to allocate for play ctx" );
644
+
645
+ ngx_rtmp_send_status (s , "NetStream.Play.Failed" , "error" ,
646
+ "Failed to allocate memory" );
647
+ }
648
+
649
+ ngx_rtmp_finalize_session (s );
650
+
629
651
return ;
630
652
}
631
653
@@ -1429,22 +1451,27 @@ ngx_rtmp_live_on_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
1429
1451
1430
1452
lacf = ngx_rtmp_get_module_app_conf (s , ngx_rtmp_live_module );
1431
1453
if (lacf == NULL ) {
1432
- ngx_log_error (NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1454
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
1433
1455
"live: FCPublish - no live config!" );
1434
1456
return NGX_ERROR ;
1435
1457
}
1436
1458
1437
1459
if (!lacf -> live || in == NULL || in -> buf == NULL ) {
1438
- ngx_log_error ( NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1460
+ ngx_log_debug0 ( NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
1439
1461
"live: FCPublish - no live or no buffer!" );
1440
1462
return NGX_OK ;
1441
1463
}
1442
1464
1443
1465
ngx_memzero (& v , sizeof (v ));
1444
- ngx_rtmp_receive_amf (s , in , in_elts ,
1445
- sizeof (in_elts ) / sizeof (in_elts [0 ]));
1466
+ if (ngx_rtmp_receive_amf (s , in , in_elts ,
1467
+ sizeof (in_elts ) / sizeof (in_elts [0 ])))
1468
+ {
1469
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
1470
+ "live: FCPublish - error receiving amf data" );
1471
+ return NGX_ERROR ;
1472
+ }
1446
1473
1447
- ngx_log_error ( NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1474
+ ngx_log_debug1 ( NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
1448
1475
"live: onFCPublish: stream='%s'" , v .stream );
1449
1476
1450
1477
return ngx_rtmp_send_fcpublish (s , v .stream );
@@ -1480,22 +1507,27 @@ ngx_rtmp_live_on_fcunpublish(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
1480
1507
1481
1508
lacf = ngx_rtmp_get_module_app_conf (s , ngx_rtmp_live_module );
1482
1509
if (lacf == NULL ) {
1483
- ngx_log_error (NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1510
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
1484
1511
"live: FCUnpublish - no live config!" );
1485
1512
return NGX_ERROR ;
1486
1513
}
1487
1514
1488
1515
if (!lacf -> live || in == NULL || in -> buf == NULL ) {
1489
- ngx_log_error ( NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1516
+ ngx_log_debug0 ( NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
1490
1517
"live: FCUnpublish - no live or no buffer!" );
1491
1518
return NGX_OK ;
1492
1519
}
1493
1520
1494
1521
ngx_memzero (& v , sizeof (v ));
1495
- ngx_rtmp_receive_amf (s , in , in_elts ,
1496
- sizeof (in_elts ) / sizeof (in_elts [0 ]));
1522
+ if (ngx_rtmp_receive_amf (s , in , in_elts ,
1523
+ sizeof (in_elts ) / sizeof (in_elts [0 ])))
1524
+ {
1525
+ ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
1526
+ "live: FCUnpublish - error receiving amf data" );
1527
+ return NGX_ERROR ;
1528
+ }
1497
1529
1498
- ngx_log_error ( NGX_LOG_DEBUG , s -> connection -> log , 0 ,
1530
+ ngx_log_debug1 ( NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
1499
1531
"live: onFCUnpublish: stream='%s'" , v .stream );
1500
1532
1501
1533
return ngx_rtmp_send_fcunpublish (s , v .stream );
0 commit comments