Skip to content
Permalink
Browse files

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.
  • Loading branch information...
LBPHacker committed Apr 8, 2019
1 parent 2ba0f70 commit 783310dc16261d590ca794382254987b031a068b
Showing with 6 additions and 6 deletions.
  1. +3 −3 src/gui/game/GameModelException.h
  2. +3 −3 src/gui/localbrowser/LocalBrowserModelException.h
@@ -5,12 +5,12 @@
#include <exception>

struct GameModelException: public exception {
String message;
ByteString message;
public:
GameModelException(String message_): message(message_) {}
GameModelException(String message_): message(message_.ToUtf8()) {}
const char * what() const throw() override
{
return message.ToUtf8().c_str();
return message.c_str();
}
~GameModelException() throw() {}
};
@@ -5,10 +5,10 @@
#include <exception>

class LocalBrowserModelException {
String message;
ByteString message;
public:
LocalBrowserModelException(String message_): message(message_) {};
const char * what() const throw() { return message.ToUtf8().c_str(); };
LocalBrowserModelException(String message_): message(message_.ToUtf8()) {};
const char * what() const throw() { return message.c_str(); };
~LocalBrowserModelException() throw() {};
};

0 comments on commit 783310d

Please sign in to comment.
You can’t perform that action at this time.