From 6d9c800fcef3adda98e9a2f60798509769f2b99e Mon Sep 17 00:00:00 2001 From: Fahnenfluchtige Date: Wed, 5 Feb 2025 19:07:25 +0300 Subject: [PATCH] Fixing memory allocation error in ngx_rtmp_live_join() --- ngx_rtmp_live_module.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ngx_rtmp_live_module.c b/ngx_rtmp_live_module.c index 5bebb9e2a..3826e8e73 100644 --- a/ngx_rtmp_live_module.c +++ b/ngx_rtmp_live_module.c @@ -504,6 +504,19 @@ ngx_rtmp_live_join(ngx_rtmp_session_t *s, u_char *name, unsigned publisher) if (ctx == NULL) { ctx = ngx_palloc(s->connection->pool, sizeof(ngx_rtmp_live_ctx_t)); + + if (ctx == NULL) { + ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, + "live: failed to allocate memory for context"); + + ngx_rtmp_send_status(s, "NetStream.Play.Failed", "error", + "Failed to allocate memory"); + + ngx_rtmp_finalize_session(s); + + return; + } + ngx_rtmp_set_ctx(s, ctx, ngx_rtmp_live_module); }