mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
exception safe bug. use vector instead of an array allocated by new[].
git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1193 e5f2f494-b856-4b98-b285-d166d9295462
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -196,14 +197,14 @@ Session::recvmsg(ElementPtr& env, ElementPtr& msg, bool nonblock)
|
|||||||
|
|
||||||
// remove the header-length bytes from the total length
|
// remove the header-length bytes from the total length
|
||||||
length -= 2;
|
length -= 2;
|
||||||
char *buffer = new char[length];
|
std::vector<char> buffer(length);
|
||||||
ret = read(sock, buffer, length);
|
ret = read(sock, &buffer[0], length);
|
||||||
if (ret != length)
|
if (ret != length) {
|
||||||
throw SessionError("Short read");
|
throw SessionError("Short read");
|
||||||
|
}
|
||||||
|
|
||||||
std::string header_wire = std::string(buffer, header_length);
|
std::string header_wire = std::string(&buffer[0], header_length);
|
||||||
std::string body_wire = std::string(buffer + header_length, length - header_length);
|
std::string body_wire = std::string(&buffer[0] + header_length, length - header_length);
|
||||||
delete [] buffer;
|
|
||||||
|
|
||||||
std::stringstream header_wire_stream;
|
std::stringstream header_wire_stream;
|
||||||
header_wire_stream << header_wire;
|
header_wire_stream << header_wire;
|
||||||
|
Reference in New Issue
Block a user