diff options
author | Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> | 2013-03-09 16:52:20 +0100 |
---|---|---|
committer | Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> | 2013-03-09 16:52:20 +0100 |
commit | 8cd298de346c1db34bc9eec8cf9096ac7ed3bdf4 (patch) | |
tree | 512196aa34322feb295e651c249fb72ee8a95e4b /core/protocol.c | |
parent | 851df339777c944c9e47db10729c5f5b0ab862db (diff) | |
download | uwsgi-8cd298de346c1db34bc9eec8cf9096ac7ed3bdf4.tar.gz |
core/protocol: fix leak in send_udp_message
By moving the allocation after some early returns in case of error.
Reported by Coverity as CID #971033.
Diffstat (limited to 'core/protocol.c')
-rw-r--r-- | core/protocol.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/protocol.c b/core/protocol.c index d69cd7dc..c3ab7012 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -28,13 +28,6 @@ ssize_t send_udp_message(uint8_t modifier1, uint8_t modifier2, char *host, char struct uwsgi_header *uh; - if (message) { - uh = (struct uwsgi_header *) message; - } - else { - uh = (struct uwsgi_header *) uwsgi_malloc(4); - } - udp_port = strchr(host, ':'); if (udp_port) { udp_port[0] = 0; @@ -64,6 +57,13 @@ ssize_t send_udp_message(uint8_t modifier1, uint8_t modifier2, char *host, char } + if (message) { + uh = (struct uwsgi_header *) message; + } + else { + uh = (struct uwsgi_header *) uwsgi_malloc(4); + } + uh->modifier1 = modifier1; #ifdef __BIG_ENDIAN__ uh->pktsize = uwsgi_swap16(message_size); |