Skip to content

Commit

Permalink
serialize: use a temporary for SerializeException
Browse files Browse the repository at this point in the history
Exception must always use temporary instead of global copied exception instances, it's not recommended and should have undefined issues
  • Loading branch information
nerzhul committed Aug 21, 2017
1 parent 1dd535c commit e2a6b7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/util/serialize.cpp
Expand Up @@ -28,8 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iomanip>
#include <vector>

SerializationError eof_ser_err("Attempted read past end of data");

////
//// BufReader
////
Expand Down
6 changes: 2 additions & 4 deletions src/util/serialize.h
Expand Up @@ -428,8 +428,6 @@ bool deSerializeStringToStruct(std::string valstr,
//// BufReader
////

extern SerializationError eof_ser_err;

#define MAKE_BUFREADER_GETNOEX_FXN(T, N, S) \
inline bool get ## N ## NoEx(T *val) \
{ \
Expand All @@ -445,7 +443,7 @@ extern SerializationError eof_ser_err;
{ \
T val; \
if (!get ## N ## NoEx(&val)) \
throw eof_ser_err; \
throw SerializationError("Attempted read past end of data"); \
return val; \
}

Expand Down Expand Up @@ -502,7 +500,7 @@ class BufReader {
inline void getRawData(void *val, size_t len)
{
if (!getRawDataNoEx(val, len))
throw eof_ser_err;
throw SerializationError("Attempted read past end of data");
}

inline size_t remaining()
Expand Down

0 comments on commit e2a6b7c

Please sign in to comment.