aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Ermakov <22344340+unspecd@users.noreply.github.com>2021-01-03 17:34:04 -0500
committerGitHub <noreply@github.com>2021-01-03 14:34:04 -0800
commitf82096d39f21f30ac11fcf1c65a5b25e85691eae (patch)
tree0a51df3b173105c42c647eef0f2a0145c19b2d5b /src
parent9c6ac231b8b7d0c597a4010135edb14b8513e3f6 (diff)
downloadnng-f82096d39f21f30ac11fcf1c65a5b25e85691eae.tar.gz
nng-f82096d39f21f30ac11fcf1c65a5b25e85691eae.tar.bz2
nng-f82096d39f21f30ac11fcf1c65a5b25e85691eae.zip
fixes #1393 Use after free in http (#1395)
Diffstat (limited to 'src')
-rw-r--r--src/supplemental/http/http_server.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c
index 1ebc8907..7f6f9abe 100644
--- a/src/supplemental/http/http_server.c
+++ b/src/supplemental/http/http_server.c
@@ -751,14 +751,16 @@ finish:
nni_aio_set_input(sc->cbaio, 1, h);
nni_aio_set_input(sc->cbaio, 2, sc->conn);
+ // Set a reference -- this because the callback may be running
+ // asynchronously even after it gets removed from the server.
+ nni_atomic_inc64(&h->ref);
+
// Documented that we call this on behalf of the callback.
if (nni_aio_begin(sc->cbaio) != 0) {
nni_mtx_unlock(&s->mtx);
return;
}
- // Set a reference -- this because the callback may be running
- // asynchronously even after it gets removed from the server.
- nni_atomic_inc64(&h->ref);
+
nni_mtx_unlock(&s->mtx);
h->cb(sc->cbaio);
}