diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-16 10:03:38 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-16 10:03:38 -0700 |
| commit | 84c32ea006f01f10cea335a9b152ec68714f46c9 (patch) | |
| tree | bfefcd8df0c9f388753d35e7c64d389b0b244c97 | |
| parent | 59ee3628d5db511ce5527ce4ddbf126e929d7da8 (diff) | |
| download | nng-84c32ea006f01f10cea335a9b152ec68714f46c9.tar.gz nng-84c32ea006f01f10cea335a9b152ec68714f46c9.tar.bz2 nng-84c32ea006f01f10cea335a9b152ec68714f46c9.zip | |
fixes #440 leak in bus protocol
| -rw-r--r-- | src/protocol/bus0/bus.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c index 01f20130..d95f54ba 100644 --- a/src/protocol/bus0/bus.c +++ b/src/protocol/bus0/bus.c @@ -297,7 +297,12 @@ bus0_sock_getq_cb(void *arg) } nni_mtx_lock(&s->mtx); - lastp = nni_list_last(&s->pipes); + if (((lastp = nni_list_last(&s->pipes)) != NULL) && + (nni_pipe_id(lastp->npipe) == sender)) { + // If the last pipe in the list is our sender, + // then ignore it and move to the one just previous. + lastp = nni_list_prev(&s->pipes, lastp); + } NNI_LIST_FOREACH (&s->pipes, p) { if (nni_pipe_id(p->npipe) == sender) { continue; @@ -308,16 +313,14 @@ bus0_sock_getq_cb(void *arg) } } else { dup = msg; + msg = NULL; } if (nni_msgq_tryput(p->sendq, dup) != 0) { nni_msg_free(dup); } } nni_mtx_unlock(&s->mtx); - - if (lastp == NULL) { - nni_msg_free(msg); - } + nni_msg_free(msg); bus0_sock_getq(s); } |
