mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
Fix oob write with stepping 'up' in the OSD history.
git-svn-id: https://svn.eduke32.com/eduke32@4725 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e8553b5398
commit
232e479380
3 changed files with 8 additions and 3 deletions
|
@ -274,6 +274,12 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar);
|
|||
void OSD_WriteAliases(FILE *fp);
|
||||
void OSD_WriteCvars(FILE *fp);
|
||||
|
||||
static inline void OSD_SetHistory(int32_t histIdx, const char *src)
|
||||
{
|
||||
osd->history.buf[histIdx] = Xmalloc(OSDEDITLENGTH);
|
||||
Bstrncpyz(osd->history.buf[histIdx], src, OSDEDITLENGTH);
|
||||
}
|
||||
|
||||
// these correspond to the Duke palettes, so they shouldn't really be here
|
||||
// ...but I don't care
|
||||
|
||||
|
|
|
@ -262,9 +262,8 @@ int32_t loadsetup(const char *fn)
|
|||
// copy script history into OSD history
|
||||
for (i=0; i<min(scripthistend, osd->history.maxlines); i++)
|
||||
{
|
||||
// Bstrncpyz(osd->history.buf[i], scripthist[scripthistend-1-i], OSDEDITLENGTH+1);
|
||||
DO_FREE_AND_NULL(osd->history.buf[i]);
|
||||
osd->history.buf[i] = Bstrdup(scripthist[scripthistend-1-i]);
|
||||
OSD_SetHistory(i, scripthist[scripthistend-1-i]);
|
||||
|
||||
osd->history.lines++;
|
||||
osd->history.total++;
|
||||
|
|
|
@ -1127,7 +1127,7 @@ int32_t OSD_HandleChar(char ch)
|
|||
|
||||
Bmemmove(&osd->history.buf[1], &osd->history.buf[0], sizeof(intptr_t) * osd->history.maxlines-1);
|
||||
|
||||
osd->history.buf[0] = Bstrdup(osd->editor.buf);
|
||||
OSD_SetHistory(0, osd->editor.buf);
|
||||
|
||||
if (osd->history.lines < osd->history.maxlines)
|
||||
osd->history.lines++;
|
||||
|
|
Loading…
Reference in a new issue