Fixed buffer overun for too wide menus

This commit is contained in:
Ianos Gnatiuc 2005-12-30 13:58:46 +00:00
parent 95d99561f9
commit 3083762d4c
3 changed files with 15 additions and 1 deletions

View File

@ -10,6 +10,8 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________
- Fixed buffer overun for too wide menus.
+ Added new config file token: XlatCharSetAlias "charset" "alias1" "alias2"...
that defines charset aliases for import tables.

View File

@ -132,6 +132,9 @@ int wopen(int srow, int scol, int erow, int ecol, int btype, int battr, int watt
return 0;
}
if (ecol >= gvid->numcols)
ecol = gvid->numcols - 1;
// see if window is to have a border
int border = (btype==5) ? NO : YES;

View File

@ -41,6 +41,10 @@
#include <gwinall.h>
#include <gwinhelp.h>
#if defined(__USE_ALLOCA__)
#include <malloc.h>
#endif
// ------------------------------------------------------------------
@ -198,10 +202,14 @@ static void close_window(int w)
static void disp_item(_item_t *witem,int bar)
{
#if defined(__USE_ALLOCA__)
char *buf = (char *)alloca(sizeof(vatch)*gvid->numcols);
#else
__extension__ char buf[sizeof(vatch)*gvid->numcols];
#endif
char ch;
int chattr;
_wrec_t* whp;
char buf[256];
register const char* p;
register vatch* ptr=(vatch*)buf;
int i, textend,width,wcol,found=NO;
@ -214,6 +222,7 @@ static void disp_item(_item_t *witem,int bar)
width = calc_bar_width(gwin.cmenu,witem);
textend = gwin.cmenu->textpos+strlen(p)-1;
wgotoxy(witem->wrow,wcol=witem->wcol);
if (width > (gvid->numcols-2)) width = gvid->numcols - 2;
// display separators
if (witem->fmask & M_SEPAR)