Skip to content

Commit 317d1cc

Browse files
committed
[misc] fix a potential crash bug, remove unused codes and update version.
1 parent dca4ef0 commit 317d1cc

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

ngx_rtmp_gop_cache_module.c

+19-15
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ static ngx_int_t
267267
ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s)
268268
{
269269
ngx_rtmp_codec_ctx_t *codec_ctx;
270-
ngx_rtmp_core_srv_conf_t *cscf;
271270
ngx_rtmp_gop_cache_ctx_t *ctx;
272271
ngx_rtmp_gop_cache_t *cache, **iter;
273272

@@ -281,11 +280,6 @@ ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s)
281280
return NGX_ERROR;
282281
}
283282

284-
cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);
285-
if (cscf == NULL) {
286-
return NGX_ERROR;
287-
}
288-
289283
if (ctx->free_cache) {
290284
cache = ctx->free_cache;
291285
ctx->free_cache = cache->next;
@@ -378,19 +372,18 @@ ngx_rtmp_gop_cache_cleanup(ngx_rtmp_session_t *s)
378372
ngx_rtmp_gop_cache_free_cache(s, cache);
379373
}
380374

381-
if (ctx->pool) {
382-
ngx_destroy_pool(ctx->pool);
383-
ctx->pool = NULL;
384-
}
385-
386375
ctx->video_seq_header = NULL;
387376
ctx->audio_seq_header = NULL;
388377
ctx->meta = NULL;
389378

390-
ctx->cache_tail = ctx->cache_head = NULL;
379+
if (ctx->cache_head) {
380+
ctx->cache_head->next = ctx->free_cache;
381+
ctx->free_cache = ctx->cache_head;
382+
ctx->cache_head = NULL;
383+
}
384+
385+
ctx->cache_tail = NULL;
391386
ctx->gop_cache_count = 0;
392-
ctx->free_cache = NULL;
393-
ctx->free_frame = NULL;
394387
ctx->video_frame_in_all = 0;
395388
ctx->audio_frame_in_all = 0;
396389
}
@@ -720,10 +713,10 @@ ngx_rtmp_gop_cache_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
720713
ngx_rtmp_live_ctx_t *ctx;
721714
ngx_rtmp_gop_cache_app_conf_t *gacf;
722715
ngx_rtmp_live_app_conf_t *lacf;
716+
ngx_rtmp_live_chunk_stream_t *cs;
723717
ngx_rtmp_header_t ch;
724718
ngx_uint_t prio;
725719
ngx_uint_t csidx;
726-
ngx_rtmp_live_chunk_stream_t *cs;
727720

728721
gacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_gop_cache_module);
729722
if (gacf == NULL || !gacf->gop_cache) {
@@ -851,6 +844,7 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
851844
ngx_rtmp_close_stream_t *v)
852845
{
853846
ngx_rtmp_live_ctx_t *ctx;
847+
ngx_rtmp_gop_cache_ctx_t *gctx;
854848
ngx_rtmp_live_app_conf_t *lacf;
855849
ngx_rtmp_gop_cache_app_conf_t *gacf;
856850

@@ -873,6 +867,16 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
873867
goto next;
874868
}
875869

870+
gctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_gop_cache_module);
871+
if (gctx == NULL) {
872+
goto next;
873+
}
874+
875+
if (gctx->pool) {
876+
ngx_destroy_pool(gctx->pool);
877+
gctx->pool = NULL;
878+
}
879+
876880
ngx_rtmp_gop_cache_cleanup(s);
877881

878882
next:

ngx_rtmp_version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define _NGX_RTMP_VERSION_H_INCLUDED_
1010

1111

12-
#define nginx_rtmp_version 1002004
13-
#define NGINX_RTMP_VERSION "1.2.4"
12+
#define nginx_rtmp_version 1002005
13+
#define NGINX_RTMP_VERSION "1.2.5"
1414

1515

1616
#endif /* _NGX_RTMP_VERSION_H_INCLUDED_ */

0 commit comments

Comments
 (0)