diff options
author | Loïc Blot <loic.blot@unix-experience.fr> | 2017-08-21 16:07:39 +0200 |
---|---|---|
committer | Loïc Blot <loic.blot@unix-experience.fr> | 2017-08-21 16:07:39 +0200 |
commit | e2a6b7c8d29a674504f80b7948a71c4a36af4ad0 (patch) | |
tree | 8d513fe60be9e4a0c0476ac3388c134a4bc5c928 | |
parent | 1dd535c0c6a80f64e6663002b92b8b2025973217 (diff) | |
download | minetest-e2a6b7c8d29a674504f80b7948a71c4a36af4ad0.tar.gz minetest-e2a6b7c8d29a674504f80b7948a71c4a36af4ad0.tar.bz2 minetest-e2a6b7c8d29a674504f80b7948a71c4a36af4ad0.zip |
serialize: use a temporary for SerializeException
Exception must always use temporary instead of global copied exception instances, it's not recommended and should have undefined issues
-rw-r--r-- | src/util/serialize.cpp | 2 | ||||
-rw-r--r-- | src/util/serialize.h | 6 |
2 files changed, 2 insertions, 6 deletions
diff --git a/src/util/serialize.cpp b/src/util/serialize.cpp index 49db9cf85..a272d82ee 100644 --- a/src/util/serialize.cpp +++ b/src/util/serialize.cpp @@ -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 //// diff --git a/src/util/serialize.h b/src/util/serialize.h index 0a1c96205..f2b0dab2f 100644 --- a/src/util/serialize.h +++ b/src/util/serialize.h @@ -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) \ { \ @@ -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; \ } @@ -502,7 +500,7 @@ public: 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() |