Skip to content

Commit 08bd780

Browse files
committed
fix bug: http-flv http-ts hls2 crashed
1 parent c47e61a commit 08bd780

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

modules/nginx-rtmp-module/http/ngx_http_flv_live_module.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ngx_http_flv_live_send_header(ngx_http_request_t *r)
131131
return NGX_HTTP_INTERNAL_SERVER_ERROR;
132132
}
133133

134-
switch (hflcf->audio | (hflcf->video < 1)) {
134+
switch (hflcf->audio | (hflcf->video << 1)) {
135135
case 1: // audio only
136136
b->start = b->pos = ngx_flv_live_audio_header;
137137
b->end = b->last = ngx_flv_live_audio_header +
@@ -528,6 +528,7 @@ ngx_http_flv_live_handler(ngx_http_request_t *r)
528528
ngx_rtmp_core_srv_conf_t *cscf;
529529
ngx_rtmp_core_app_conf_t **cacfp;
530530
ngx_http_cleanup_t *cln;
531+
ngx_rtmp_core_main_conf_t *cmcf;
531532

532533
rc = ngx_http_discard_request_body(r);
533534

@@ -612,6 +613,13 @@ ngx_http_flv_live_handler(ngx_http_request_t *r)
612613
s->stage = NGX_LIVE_PLAY;
613614
s->ptime = ngx_current_msec;
614615

616+
cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);
617+
s->variables = ngx_pcalloc(s->pool, cmcf->variables.nelts
618+
* sizeof(ngx_http_variable_value_t));
619+
if (s->variables == NULL) {
620+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
621+
}
622+
615623
if (ngx_rtmp_play_filter(s, &v) != NGX_OK) {
616624
return NGX_HTTP_INTERNAL_SERVER_ERROR;
617625
}

modules/nginx-rtmp-module/mpegts/ngx_hls_http_module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ ngx_hls_http_create_session(ngx_http_request_t *r)
611611
ngx_uint_t n;
612612
ngx_rtmp_core_srv_conf_t *cscf;
613613
ngx_rtmp_core_app_conf_t **cacfp;
614+
ngx_rtmp_core_main_conf_t *cmcf;
614615

615616
hlcf = ngx_http_get_module_loc_conf(r, ngx_hls_http_module);
616617

@@ -678,6 +679,13 @@ ngx_hls_http_create_session(ngx_http_request_t *r)
678679
s->ptime = ngx_current_msec;
679680
// s->connection = r->connection;
680681

682+
cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);
683+
s->variables = ngx_pcalloc(s->pool, cmcf->variables.nelts
684+
* sizeof(ngx_http_variable_value_t));
685+
if (s->variables == NULL) {
686+
return NULL;
687+
}
688+
681689
if (ngx_rtmp_play_filter(s, &v) != NGX_OK) {
682690
return NULL;
683691
}

modules/nginx-rtmp-module/mpegts/ngx_mpegts_http_module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ ngx_mpegts_http_handler(ngx_http_request_t *r)
433433
ngx_rtmp_core_srv_conf_t *cscf;
434434
ngx_rtmp_core_app_conf_t **cacfp;
435435
ngx_http_cleanup_t *cln;
436+
ngx_rtmp_core_main_conf_t *cmcf;
436437

437438
ctx = ngx_pcalloc(r->pool, sizeof(ngx_mpegts_http_ctx_t));
438439
if (ctx == NULL) {
@@ -512,6 +513,13 @@ ngx_mpegts_http_handler(ngx_http_request_t *r)
512513
s->stage = NGX_LIVE_PLAY;
513514
s->ptime = ngx_current_msec;
514515

516+
cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);
517+
s->variables = ngx_pcalloc(s->pool, cmcf->variables.nelts
518+
* sizeof(ngx_http_variable_value_t));
519+
if (s->variables == NULL) {
520+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
521+
}
522+
515523
if (ngx_rtmp_play_filter(s, &v) != NGX_OK) {
516524
return NGX_HTTP_INTERNAL_SERVER_ERROR;
517525
}

release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ then
178178
apt-get install -y libpcre3 libpcre3-dev
179179
apt-get install -y zlib1g-dev
180180
apt-get install -y openssl
181+
apt-get install -y libssl-dev
181182

182183
elif [ "$CMD" == "brew" ]
183184
then

0 commit comments

Comments
 (0)