1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fixed memory leak in Packet's copy assignment operator.

This commit is contained in:
Matias Fontanini
2012-11-26 15:03:09 -03:00
parent cd6bc16d48
commit 16a29fab3e
4 changed files with 30 additions and 6 deletions

View File

@@ -156,9 +156,11 @@ public:
* This calls PDU::clone on the rhs's PDU* member.
*/
Packet& operator=(const Packet &rhs) {
ts = rhs.timestamp();
if(rhs.pdu())
pdu_ = rhs.pdu()->clone();
if(this != &rhs) {
delete pdu_;
ts = rhs.timestamp();
pdu_ = rhs.pdu() ? rhs.pdu()->clone() : 0;
}
return *this;
}
@@ -174,8 +176,10 @@ public:
* Move assignment operator.
*/
Packet& operator=(Packet &&rhs){
std::swap(pdu_, rhs.pdu_);
ts = rhs.timestamp();
if(this != &rhs) {
std::swap(pdu_, rhs.pdu_);
ts = rhs.timestamp();
}
return *this;
}
#endif

View File

@@ -71,7 +71,7 @@ void PDU::send(PacketSender &) {
}
PDU *PDU::recv_response(PacketSender &) {
return false;
return 0;
}
void PDU::inner_pdu(PDU *next_pdu) {

14
tests/configure vendored
View File

@@ -652,6 +652,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_c__11
'
ac_precious_vars='build_alias
host_alias
@@ -1270,6 +1271,12 @@ if test -n "$ac_init_help"; then
esac
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-c++11 enable C++11 features
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
@@ -2509,6 +2516,13 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CFLAGS="-DTINS_DEBUG -g"
# Check whether --enable-c++11 was given.
if test "${enable_c__11+set}" = set; then :
enableval=$enable_c__11; CFLAGS="$CFLAGS -std=c++0x"
fi
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'

View File

@@ -5,6 +5,12 @@ AC_LANG(C++)
CFLAGS="-DTINS_DEBUG -g"
AC_ARG_ENABLE(
c++11,
[ --enable-c++11 enable C++11 features],
[CFLAGS="$CFLAGS -std=c++0x"]
)
AC_CHECK_HEADERS([pcap.h gtest/gtest.h])
AC_CHECK_LIB(pcap, pcap_loop, [], [AC_MSG_ERROR([pcap library is needed!])])
#AC_CHECK_LIB([gtest_main], [main], [], [AC_MSG_ERROR([gtest library is needed!])])