Skip to content

Fixing unchecked value#1789

Open
Fahnenfluchtige wants to merge 4 commits intoarut:masterfrom
Fahnenfluchtige:fixing_unchecked_value
Open

Fixing unchecked value#1789
Fahnenfluchtige wants to merge 4 commits intoarut:masterfrom
Fahnenfluchtige:fixing_unchecked_value

Conversation

@Fahnenfluchtige
Copy link

The Svace static analysis tool identified a potential issue in the function ngx_rtmp_init_event_handlers(), where the return value of ngx_array_init is not checked properly:

 ngx_array_init(&cmcf->amf_arrays, cf->pool, 1, sizeof(ngx_hash_key_t));

The function сan return NGX_ERROR. However, no error handling is performed.

So, the solution is to add error checking:

diff --git a/ngx_rtmp.c b/ngx_rtmp.c
index cde7432..fc0ef24 100644
--- a/ngx_rtmp.c
+++ b/ngx_rtmp.c
@@ -449,7 +449,9 @@ ngx_rtmp_init_event_handlers(ngx_conf_t *cf, ngx_rtmp_core_main_conf_t *cmcf)
     *eh = ngx_rtmp_aggregate_message_handler;
 
     /* init amf callbacks */
-    ngx_array_init(&cmcf->amf_arrays, cf->pool, 1, sizeof(ngx_hash_key_t));
+    if (ngx_array_init(&cmcf->amf_arrays, cf->pool, 1, sizeof(ngx_hash_key_t)) != NGX_OK) {
+        return NGX_ERROR;
+    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant