I have been using this Requster on OS3.9 for a long time. Now I am moving to OS4.1FE. It crashes whenever there are args:
Works:
SAK_EasyRequest(Objects[OID_WINDOW],MainWindow,RequesterTitle,0,NULL,"Name:Mark\nCountry:USA",0,SAK_LocaleString(MSG_TERMINATE));
Crashes:
SAK_EasyRequest(Objects[OID_WINDOW],MainWindow,RequesterTitle,0,NULL,"Name:%s\nCountry:%s",0,SAK_LocaleString(MSG_TERMINATE),"Mark","USA");
Is the vsprintf() not GCC/OS4.1 friendly?
VARARGS68K int32 SAK_EasyRequest(Object *WinObject,struct Window *Window,STRPTR Title,int32 ImageType,struct Image *Image,STRPTR Text,uint32 Timer,STRPTR Gadgets,...) { Object *Requester; int32 Result; char VABuffer[1024]; va_list VarArgs; va_startlinear(VarArgs,Gadgets); vsprintf(VABuffer,Text,va_getlinearva(VarArgs,void*)); va_end(VarArgs); if (!(Requester=RequesterObject, REQ_TitleText, Title, REQ_Type, 0, REQ_Image, ImageType ? REQIMAGE_ERROR : REQIMAGE_INFO, REQ_BodyText, VABuffer, REQ_WrapBorder, 35, REQ_TimeOutSecs, Timer, REQ_GadgetText, Gadgets, REQ_StayOnTop, TRUE, TAG_END))) return(-99); Result=DoMethod(Requester,RM_OPENREQ,NULL,Window,NULL); DisposeObject(Requester); // Timer? Result==-1 return(Result); }
You're using linear varargs but vsprintf() expects normal varargs.
Also you should use vsnprintf() instead of vsprintf() to protect against buffer overflows.
That is the way I originally had it; it worked that way. I was looking around here and everyone was using the linear code so I switched to that thinking it was "the new OS4 way to do it."
What is the difference? When do you use that?
Thanks