Skip to content

Commit af0c17f

Browse files
author
Simon Lepasteur
committed
Fix nullptr defined as 0 on g++.
SafeInt3.hpp used an invalid check to determine wether nullptr should be defined as 0 with g++ compiler. Checking that we use c++11 or above fixed the issue. However, using a valid check broke the compilation because boost::function cannot be resetted by assigning a nullptr to it. Using default constructed boost::function for reset fixed this.
1 parent d241d00 commit af0c17f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Release/include/cpprest/details/SafeInt3.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ Version 3.0
118118
#define NEEDS_NULLPTR_DEFINED 1
119119
#endif
120120
#else
121-
// Let everything else trigger based on whether we have nullptr_t
122-
#if defined nullptr_t
121+
// Let everything else trigger based on whether we use c++11 or above
122+
#if __cplusplus >= 201103L
123123
#define NEEDS_NULLPTR_DEFINED 0
124124
#else
125125
#define NEEDS_NULLPTR_DEFINED 1

Release/libs/websocketpp/websocketpp/transport/asio/connection.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ class connection : public config::socket_type::socket_con_type {
442442
if (ec) {
443443
// reset the handlers to break the circular reference:
444444
// this->handler->this
445-
m_async_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
446-
m_async_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
445+
m_async_read_handler = async_read_handler{};
446+
m_async_write_handler = async_write_handler{};
447447
}
448448

449449
return ec;
@@ -969,12 +969,12 @@ class connection : public config::socket_type::socket_con_type {
969969
// Reset cached handlers now that we won't be reading or writing anymore
970970
// These cached handlers store shared pointers to this connection and
971971
// will leak the connection if not destroyed.
972-
m_async_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
973-
m_async_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
974-
m_init_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
972+
m_async_read_handler = async_read_handler{};
973+
m_async_write_handler = async_write_handler{};
974+
m_init_handler = init_handler{};
975975

976-
m_read_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
977-
m_write_handler = _WEBSOCKETPP_NULLPTR_TOKEN_;
976+
m_read_handler = read_handler{};
977+
m_write_handler = write_handler{};
978978

979979
timer_ptr shutdown_timer;
980980
shutdown_timer = set_timer(

0 commit comments

Comments
 (0)