Changeset 50:264c9f2e9094 in rrlib_logging


Ignore:
Timestamp:
09.01.2011 01:58:11 (10 years ago)
Author:
Max Reichardt <reichardt@…>
Branch:
default
Phase:
public
Convert:
svn:2179b62a-598e-4714-ba03-d8986cbf34aa/trunk@51
Message:

(Somewhat ugly) Bugfix.
(Using va_list twice can lead to undefined behaviour. "The problem is, once you pass the value of a va_list, that va_list object is "dead" and can only be handed to va_end.")

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tLogDomain.h

    r49 r50  
    284284    } 
    285285 
     286    va_list printf_args0; 
     287    va_start(printf_args0, fmt); 
     288    char temp; 
     289    int needed_buffer_size = vsnprintf(&temp, 1, fmt, printf_args0); 
     290    va_end(printf_args0); 
     291 
    286292    va_list printf_args; 
    287293    va_start(printf_args, fmt); 
    288     this->VPrintMessage(description, function, file, line, level, fmt, printf_args); 
     294    this->VPrintMessage(description, function, file, line, level, fmt, needed_buffer_size, printf_args); 
    289295    va_end(printf_args); 
    290296  } 
     
    298304    } 
    299305 
     306    va_list printf_args0; 
     307    va_start(printf_args0, fmt); 
     308    char temp; 
     309    int needed_buffer_size = vsnprintf(&temp, 1, fmt, printf_args0); 
     310    va_end(printf_args0); 
     311 
    300312    va_list printf_args; 
    301313    va_start(printf_args, fmt); 
    302     this->VPrintMessage(description, function, file, line, level, fmt, printf_args); 
     314    this->VPrintMessage(description, function, file, line, level, fmt, needed_buffer_size, printf_args); 
    303315    va_end(printf_args); 
    304316  } 
     
    424436 
    425437  template <typename TDescription> 
    426   inline void VPrintMessage(const TDescription &description, const char *function, const char *file, int line, tLogLevel level, const char *fmt,  va_list printf_args) const 
    427   { 
    428     char temp; 
    429     int needed_buffer_size = vsnprintf(&temp, 1, fmt, printf_args); 
     438  inline void VPrintMessage(const TDescription &description, const char *function, const char *file, int line, tLogLevel level, const char *fmt, int needed_buffer_size, va_list printf_args) const 
     439  { 
    430440    if (needed_buffer_size > 0) 
    431441    { 
Note: See TracChangeset for help on using the changeset viewer.