Use-after-free when saving Qt message history #996
Possibly resolve #996
This commit is contained in:
+4
-3
@@ -100,9 +100,10 @@ const char * NetHackQtMessageWindow::GetStr(bool init)
|
|||||||
QListWidgetItem *item = list->item(currgetmsg++);
|
QListWidgetItem *item = list->item(currgetmsg++);
|
||||||
if (item) {
|
if (item) {
|
||||||
QString str = item->text();
|
QString str = item->text();
|
||||||
const char *result = str.toLatin1().constData();
|
if (str.toLatin1().length() < (int) sizeof historybuf - 1) {
|
||||||
//raw_printf("getstr[%d]='%s'", currgetmsg, result);
|
return strcpy(historybuf, str.toLatin1().constData());
|
||||||
return result;
|
//raw_printf("getstr[%d]='%s'", currgetmsg, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ private:
|
|||||||
bool changed;
|
bool changed;
|
||||||
int currgetmsg;
|
int currgetmsg;
|
||||||
NetHackQtMapWindow2* map;
|
NetHackQtMapWindow2* map;
|
||||||
|
char historybuf[BUFSZ];
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateFont();
|
void updateFont();
|
||||||
|
|||||||
Reference in New Issue
Block a user