Apr 252009

A subtle bug has been discovered in one of the logging functions in the IPlug portion of the WDL framework. Details below:

First the bug in the logging code. Check out wdl\IPlug\Log.cpp

const char* AppendTimestamp(const char* Mmm_dd_yyyy, const char* hh_mm_ss, const char* cStr)
    static WDL_String str(cStr);
    WDL_String tStr;
    CompileTimestamp(Mmm_dd_yyyy, hh_mm_ss, &tStr);
    str.Append(" ");
    return str.Get();

The subtle bug here concerns the static object str of type WDL_String. Since this object is static it will only have its constructor evaluated the first time this function is called. So the first call to this function will append the timestamp to the passed in string, but the second call to this function will append the timestamp to the previously passed in string with the previous timestamp. So the second call returns with two timestamps on it. The third call with three and so on. The fix is easy. Change line 174 to the following two lines which will set the base string to the passed in string every time.

    static WDL_String str;

Thanks to Patrick Cyr for finding this bug.

Sorry, the comment form is closed at this time.