TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Bug in check_all_events()

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
stef70



Joined: 22 Jan 2010
Posts: 9

PostPosted: Sat Dec 18, 2010 3:17 am    Post subject: Bug in check_all_events() Reply with quote

If hit a bug in check_all_events() while trying to use GMCP events. The values returned by the va_arg() macros are inconsistent!

The problem is in the way the va_list object is used:

Code:

  va_list list;
  va_start(list, fmt);
  vsprintf(buf, fmt, list);
  ...
  ... va_arg(list, char *) ...
  ...
  va_end(list);


On Linux, at least, the man page of vsprintf clearly states

Code:

 ... Because they invoke the va_arg macro, the value of ap is  undefined after the call


The current implementation may work on some systems (vsprintf does not necessarily modify 'list') but to be portable the 'list' variable should be reinitialized before starting calling va_arg().

I patched the code as follow and it works fine:
Code:

   va_list list;
 
   va_start(list, fmt);
   vsprintf(buf, fmt, list);
   va_end(list);
 
   va_start(list, fmt);   
   ...
   ... va_arg(list, char *) ...
   ...
   va_end(list) ;
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sat Dec 18, 2010 9:31 am    Post subject: Reply with quote

Probably safest to do it that way. I've got it changed for the next release. Smile
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group