Commit 7496b7c5 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

fixed exception unsafeness bug

git-svn-id: svn:// e5f2f494-b856-4b98-b285-d166d9295462
parent c4dfe9dc
......@@ -157,17 +157,17 @@ Session::recvmsg(ElementPtr& msg, bool nonblock)
if (header_length != length) {
throw SessionError("Received non-empty body where only a header expected");
char *buffer = new char[length];
ret = read(sock, buffer, length);
if (ret != length)
std::vector<char> buffer(length);
ret = read(sock, &buffer[0], length);
if (ret != length) {
throw SessionError("Short read");
std::string wire = std::string(buffer, length);
delete [] buffer;
std::string wire = std::string(&buffer[0], length);
std::stringstream wire_stream;
wire_stream <<wire;
wire_stream << wire;
msg = Element::fromWire(wire_stream, length);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment