Skip to content

Commit

Permalink
[misc] fix a potential crash bug, remove unused codes and update vers…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
winshining committed Sep 13, 2018
1 parent dca4ef0 commit 317d1cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
34 changes: 19 additions & 15 deletions ngx_rtmp_gop_cache_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ static ngx_int_t
ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s)
{
ngx_rtmp_codec_ctx_t *codec_ctx;
ngx_rtmp_core_srv_conf_t *cscf;
ngx_rtmp_gop_cache_ctx_t *ctx;
ngx_rtmp_gop_cache_t *cache, **iter;

Expand All @@ -281,11 +280,6 @@ ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s)
return NGX_ERROR;
}

cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);
if (cscf == NULL) {
return NGX_ERROR;
}

if (ctx->free_cache) {
cache = ctx->free_cache;
ctx->free_cache = cache->next;
Expand Down Expand Up @@ -378,19 +372,18 @@ ngx_rtmp_gop_cache_cleanup(ngx_rtmp_session_t *s)
ngx_rtmp_gop_cache_free_cache(s, cache);
}

if (ctx->pool) {
ngx_destroy_pool(ctx->pool);
ctx->pool = NULL;
}

ctx->video_seq_header = NULL;
ctx->audio_seq_header = NULL;
ctx->meta = NULL;

ctx->cache_tail = ctx->cache_head = NULL;
if (ctx->cache_head) {
ctx->cache_head->next = ctx->free_cache;
ctx->free_cache = ctx->cache_head;
ctx->cache_head = NULL;
}

ctx->cache_tail = NULL;
ctx->gop_cache_count = 0;
ctx->free_cache = NULL;
ctx->free_frame = NULL;
ctx->video_frame_in_all = 0;
ctx->audio_frame_in_all = 0;
}
Expand Down Expand Up @@ -720,10 +713,10 @@ ngx_rtmp_gop_cache_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ngx_rtmp_live_ctx_t *ctx;
ngx_rtmp_gop_cache_app_conf_t *gacf;
ngx_rtmp_live_app_conf_t *lacf;
ngx_rtmp_live_chunk_stream_t *cs;
ngx_rtmp_header_t ch;
ngx_uint_t prio;
ngx_uint_t csidx;
ngx_rtmp_live_chunk_stream_t *cs;

gacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_gop_cache_module);
if (gacf == NULL || !gacf->gop_cache) {
Expand Down Expand Up @@ -851,6 +844,7 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
ngx_rtmp_close_stream_t *v)
{
ngx_rtmp_live_ctx_t *ctx;
ngx_rtmp_gop_cache_ctx_t *gctx;
ngx_rtmp_live_app_conf_t *lacf;
ngx_rtmp_gop_cache_app_conf_t *gacf;

Expand All @@ -873,6 +867,16 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
goto next;
}

gctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_gop_cache_module);
if (gctx == NULL) {
goto next;
}

if (gctx->pool) {
ngx_destroy_pool(gctx->pool);
gctx->pool = NULL;
}

ngx_rtmp_gop_cache_cleanup(s);

next:
Expand Down
4 changes: 2 additions & 2 deletions ngx_rtmp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define _NGX_RTMP_VERSION_H_INCLUDED_


#define nginx_rtmp_version 1002004
#define NGINX_RTMP_VERSION "1.2.4"
#define nginx_rtmp_version 1002005
#define NGINX_RTMP_VERSION "1.2.5"


#endif /* _NGX_RTMP_VERSION_H_INCLUDED_ */

0 comments on commit 317d1cc

Please sign in to comment.