show correct exceptions: fix exception memory access bug

This commit is contained in:
Marc Wäckerlin
2018-11-14 11:30:28 +01:00
parent 657c67fcf4
commit 7c7786eb04
3 changed files with 5 additions and 5 deletions

View File

@@ -1 +1 @@
/usr/share/automake-1.13/COPYING /usr/share/automake-1.15/COPYING

View File

@@ -1 +1 @@
/usr/share/automake-1.13/INSTALL /usr/share/automake-1.15/INSTALL

View File

@@ -16,8 +16,9 @@ class Exception: public std::exception {
Exception(QString w): _what(w) {} Exception(QString w): _what(w) {}
~Exception() throw() {} ~Exception() throw() {}
const char* what() const throw() { const char* what() const throw() {
_bytes = _what.toUtf8(); static QByteArray bytes;
return _bytes.data(); bytes = _what.toUtf8();
return bytes.data();
} }
void line(int linenr) { void line(int linenr) {
if (linenr>0) _what=QString::number(linenr)+" "+_what; if (linenr>0) _what=QString::number(linenr)+" "+_what;
@@ -26,7 +27,6 @@ class Exception: public std::exception {
if (filename.size()) _what=filename+":"+_what; if (filename.size()) _what=filename+":"+_what;
} }
protected: protected:
QByteArray _bytes;
QString _what; QString _what;
}; };