mirror of
https://github.com/minetest/minetest.git
synced 2024-12-02 12:33:45 +01:00
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
This commit is contained in:
parent
12562be393
commit
d9c7af109a
@ -28,8 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
SerializationError eof_ser_err("Attempted read past end of data");
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// BufReader
|
//// BufReader
|
||||||
////
|
////
|
||||||
|
@ -429,8 +429,6 @@ bool deSerializeStringToStruct(std::string valstr,
|
|||||||
//// BufReader
|
//// BufReader
|
||||||
////
|
////
|
||||||
|
|
||||||
extern SerializationError eof_ser_err;
|
|
||||||
|
|
||||||
#define MAKE_BUFREADER_GETNOEX_FXN(T, N, S) \
|
#define MAKE_BUFREADER_GETNOEX_FXN(T, N, S) \
|
||||||
inline bool get ## N ## NoEx(T *val) \
|
inline bool get ## N ## NoEx(T *val) \
|
||||||
{ \
|
{ \
|
||||||
@ -446,7 +444,7 @@ extern SerializationError eof_ser_err;
|
|||||||
{ \
|
{ \
|
||||||
T val; \
|
T val; \
|
||||||
if (!get ## N ## NoEx(&val)) \
|
if (!get ## N ## NoEx(&val)) \
|
||||||
throw eof_ser_err; \
|
throw SerializationError("Attempted read past end of data"); \
|
||||||
return val; \
|
return val; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +502,7 @@ public:
|
|||||||
inline void getRawData(void *val, size_t len)
|
inline void getRawData(void *val, size_t len)
|
||||||
{
|
{
|
||||||
if (!getRawDataNoEx(val, len))
|
if (!getRawDataNoEx(val, len))
|
||||||
throw eof_ser_err;
|
throw SerializationError("Attempted read past end of data");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t remaining()
|
inline size_t remaining()
|
||||||
|
Loading…
Reference in New Issue
Block a user