mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 12:02:40 +02:00
Fix a few exceptions returning pointers to temporaries in what()
LocalBrowserModelException and GameModelException returned pointers to data owned by temporaries in what(). Solution: don't create a temporary in what(), store the ByteString version of the error message in the exception.
This commit is contained in:
@@ -5,12 +5,12 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
struct GameModelException: public exception {
|
struct GameModelException: public exception {
|
||||||
String message;
|
ByteString message;
|
||||||
public:
|
public:
|
||||||
GameModelException(String message_): message(message_) {}
|
GameModelException(String message_): message(message_.ToUtf8()) {}
|
||||||
const char * what() const throw() override
|
const char * what() const throw() override
|
||||||
{
|
{
|
||||||
return message.ToUtf8().c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
~GameModelException() throw() {}
|
~GameModelException() throw() {}
|
||||||
};
|
};
|
||||||
|
@@ -5,10 +5,10 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
class LocalBrowserModelException {
|
class LocalBrowserModelException {
|
||||||
String message;
|
ByteString message;
|
||||||
public:
|
public:
|
||||||
LocalBrowserModelException(String message_): message(message_) {};
|
LocalBrowserModelException(String message_): message(message_.ToUtf8()) {};
|
||||||
const char * what() const throw() { return message.ToUtf8().c_str(); };
|
const char * what() const throw() { return message.c_str(); };
|
||||||
~LocalBrowserModelException() throw() {};
|
~LocalBrowserModelException() throw() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user