aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2023-04-19 21:24:38 -0700
committerGarrett D'Amore <garrett@damore.org>2023-04-19 21:24:38 -0700
commit0c22b5830f59e59851f6eab65fd692de6c6c1a0c (patch)
tree1da30a8fc651d1857710fffbfa5548a044a237f7 /src/core
parent8e1836f57e8bcdb228dd5baadc71dfbf30b544e0 (diff)
downloadnng-0c22b5830f59e59851f6eab65fd692de6c6c1a0c.tar.gz
nng-0c22b5830f59e59851f6eab65fd692de6c6c1a0c.tar.bz2
nng-0c22b5830f59e59851f6eab65fd692de6c6c1a0c.zip
fixes #1610 nni_sock_open() in socket.c: use after free
Diffstat (limited to 'src/core')
-rw-r--r--src/core/socket.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 09535676..1e7d978e 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1,5 +1,5 @@
//
-// Copyright 2022 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -640,8 +640,10 @@ nni_sock_open(nni_sock **sockp, const nni_proto *proto)
}
nni_mtx_lock(&sock_lk);
- if (nni_id_alloc(&sock_ids, &s->s_id, s) != 0) {
+ if ((rv = nni_id_alloc(&sock_ids, &s->s_id, s)) != 0) {
+ nni_mtx_unlock(&sock_lk);
sock_destroy(s);
+ return (rv);
} else {
nni_list_append(&sock_list, s);
s->s_sock_ops.sock_open(s->s_data);