Merge pull request #76 from maxim-ky/master

Made some destructors virtual and fixed a user-after-free bug
This commit is contained in:
Martijn Otto 2016-07-04 09:38:31 +02:00 committed by GitHub
commit 979128782b
13 changed files with 26 additions and 8 deletions

View File

@ -25,7 +25,7 @@ add_subdirectory(src)
add_subdirectory(include)
add_library(amqp-cpp STATIC ${SRCS})
target_include_directories(amqp-cpp SYSTEM PUBLIC ${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR})
install(TARGETS amqp-cpp
ARCHIVE DESTINATION lib
)

View File

@ -1,4 +1,4 @@
PREFIX = /usr
PREFIX ?= /usr
INCLUDE_DIR = ${PREFIX}/include
LIBRARY_DIR = ${PREFIX}/lib
export LIBRARY_NAME = amqpcpp

View File

@ -31,6 +31,11 @@ namespace AMQP {
class Buffer
{
public:
/**
* Destructor
*/
virtual ~Buffer() {}
/**
* Total size of the buffer
* @return size_t

View File

@ -36,6 +36,11 @@ class Connection;
class ConnectionHandler
{
public:
/**
* Destructor
*/
virtual ~ConnectionHandler() = default;
/**
* Method that is called when the heartbeat frequency is negotiated
* between the server and the client. You normally do not have to

View File

@ -20,6 +20,7 @@
*/
#include "envelope.h"
#include <limits>
#include <stdexcept>
/**
* Set up namespace

View File

@ -115,7 +115,7 @@ public:
/**
* Destructor
*/
virtual ~TcpConnection() = default;
virtual ~TcpConnection() noexcept {}
/**
* Process the TCP connection

View File

@ -30,6 +30,11 @@ class TcpConnection;
class TcpHandler
{
public:
/**
* Destructor
*/
virtual ~TcpHandler() {}
/**
* Method that is called when the heartbeat frequency is negotiated
* between the server and the client.

View File

@ -123,7 +123,8 @@ uint64_t ConnectionImpl::parse(const Buffer &buffer)
try
{
// try to recognize the frame
ReceivedFrame receivedFrame(ReducedBuffer(buffer, processed), _maxFrame);
ReducedBuffer reduced_buf(buffer, processed);
ReceivedFrame receivedFrame(reduced_buf, _maxFrame);
// do we have the full frame?
if (receivedFrame.complete())

View File

@ -27,6 +27,7 @@
#include <unistd.h>
#include <netinet/tcp.h>
#include <functional>
#include <stdexcept>
// forward declarations
#include "../include/classes.h"

View File

@ -47,7 +47,7 @@ Table::Table(const Table &table)
// since a map is always ordered, we know that each element will
// be inserted at the end of the new map, so we can simply use
// emplace_hint and hint at insertion at the end of the map
_fields.emplace_hint(_fields.end(), std::make_pair(iter->first, iter->second->clone()));
_fields.insert(_fields.end(), std::make_pair(iter->first, iter->second->clone()));
}
}

View File

@ -41,7 +41,7 @@ public:
/**
* Destructor
*/
virtual ~TcpClosed() = default;
virtual ~TcpClosed() noexcept = default;
};
/**

View File

@ -108,7 +108,7 @@ public:
/**
* Destructor
*/
virtual ~TcpConnected()
virtual ~TcpConnected() noexcept
{
// we no longer have to monitor the socket
_handler->monitor(_connection, _socket, 0);

View File

@ -158,7 +158,7 @@ public:
/**
* Destructor
*/
virtual ~TcpResolver()
virtual ~TcpResolver() noexcept
{
// stop monitoring the pipe filedescriptor
_handler->monitor(_connection, _pipe.in(), 0);