diff options
author | Vincent Richard <[email protected]> | 2016-03-03 19:16:21 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2016-03-03 19:16:21 +0000 |
commit | 7d2ef7311e0c380233083248474f2c8534257271 (patch) | |
tree | 0548242295d28b69fdeae165d2a08ca34fa85997 | |
parent | Asynchronous resolving. (diff) | |
download | vmime-7d2ef7311e0c380233083248474f2c8534257271.tar.gz vmime-7d2ef7311e0c380233083248474f2c8534257271.zip |
Fixed #132: invalid pointer to temporary buffer.
-rw-r--r-- | src/vmime/platforms/posix/posixSocket.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/vmime/platforms/posix/posixSocket.cpp b/src/vmime/platforms/posix/posixSocket.cpp index aa5ec58a..7272eed1 100644 --- a/src/vmime/platforms/posix/posixSocket.cpp +++ b/src/vmime/platforms/posix/posixSocket.cpp @@ -44,6 +44,7 @@ #include <fcntl.h> #include <errno.h> #include <string.h> +#include <stdio.h> #include "vmime/utility/stringUtils.hpp" @@ -363,9 +364,8 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port void posixSocket::resolve(struct ::addrinfo** addrInfo, const vmime::string& address, const vmime::port_t port) { - std::ostringstream portStr; - portStr.imbue(std::locale::classic()); - portStr << port; + char portStr[16]; + snprintf(portStr, sizeof(portStr), "%u", static_cast <unsigned int>(port)); struct ::addrinfo hints; @@ -384,7 +384,7 @@ void posixSocket::resolve(struct ::addrinfo** addrInfo, const vmime::string& add memset(&gaiRequest, 0, sizeof(gaiRequest)); gaiRequest.ar_name = address.c_str(); - gaiRequest.ar_service = portStr.str().c_str(); + gaiRequest.ar_service = portStr; gaiRequest.ar_request = &hints; struct ::gaicb* gaiRequests = &gaiRequest; |