fix off-by-one (premature-truncation, not overflow)

This commit is contained in:
nhmall
2023-03-10 13:54:44 -05:00
parent b61f55f0e4
commit 8e05a06d24
+1 -1
View File
@@ -100,7 +100,7 @@ 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();
if (str.toLatin1().length() < (int) sizeof historybuf - 1) { if (str.toLatin1().length() < (int) sizeof historybuf) {
return strcpy(historybuf, str.toLatin1().constData()); return strcpy(historybuf, str.toLatin1().constData());
//raw_printf("getstr[%d]='%s'", currgetmsg, result); //raw_printf("getstr[%d]='%s'", currgetmsg, result);
} }