From e69af756d892bba02a5ec285f62f8ec9114ef647 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Tue, 1 Jun 2004 04:18:17 +0000 Subject: [PATCH] Fix long title support (Back to using malloc()) --- src/uifc/uifc32.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/uifc/uifc32.c b/src/uifc/uifc32.c index fe36ca756d..846959e387 100644 --- a/src/uifc/uifc32.c +++ b/src/uifc/uifc32.c @@ -587,9 +587,14 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar uint s_bottom=api->scrn_len-3; uint title_len; struct uifc_mouse_event mevnt; - char title[MAX_OPLN]; + char *title; - sprintf(title,"%.*s",sizeof(title)-1,initial_title); + if((title=(char *)MALLOC(strlen(initial_title)+1))==NULL) { + cprintf("UIFC line %d: error allocating %u bytes." + ,__LINE__,strlen(title)+1); + return(-1); + } + strcpy(title,initial_title); hidemouse(); title_len=strlen(title); @@ -631,6 +636,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar *(title+width-6)='.'; *(title+width-5)='.'; *(title+width-4)=0; + title_len=strlen(title); } } if(mode&WIN_L2R) @@ -665,6 +671,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if((sav[api->savnum].buf=(char *)MALLOC((width+3)*(height+2)*2))==NULL) { cprintf("UIFC line %d: error allocating %u bytes." ,__LINE__,(width+3)*(height+2)*2); + free(title); return(-1); } gettext(s_left+left,s_top+top,s_left+left+width+1 @@ -686,6 +693,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar if((sav[api->savnum].buf=(char *)MALLOC((width+3)*(height+2)*2))==NULL) { cprintf("UIFC line %d: error allocating %u bytes." ,__LINE__,(width+3)*(height+2)*2); + free(title); return(-1); } gettext(s_left+left,s_top+top,s_left+left+width+1 @@ -911,6 +919,7 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar else y=top+3+(*cur); } + free(title); last_menu_cur=cur; last_menu_bar=bar; -- GitLab