(wx-2.8.7) wxDateTime::MakeFromTimeZone problem with negative offset

Vadim Zeitlin vadim at wxwidgets.org
Sun Dec 30 15:26:13 PST 2007


On Wed, 26 Dec 2007 13:42:41 +0100 JC Francois <jc.francois at gmail.com> wrote:

JF> Digging into the source code of wxDateTime::ParseRfc822Date() I found 
JF> that this method handles the offset correctly but then on line 3003 of 
JF> datetime.cpp it calls:
JF> 
JF>     MakeFromTimeZone(TimeZone((wxDateTime_t)(offset*SEC_PER_MIN)));
JF> 
JF> Now in the second case described above the value of the variable 
JF> 'offset' is negative BUT wxDateTime_t is defined (in datetime.h, line 
JF> 151) as :
JF> 
JF>     typedef unsigned short wxDateTime_t;
JF> 
JF> So the negative int offset value is forced into an unsigned short and 
JF> gets corrupted.

 Thanks for finding this bug! I've fixed it in the svn trunk in an obvious
way (use "long" instead of "wxDateTime_t" in TimeZone ctor) but I had to
add a special TimeZone::Make() method in 2.8 to avoid changing the ABI
there.

 Anyhow, this should work correctly now (the unit test using your value
passes now), thanks again for finding the bug.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/




More information about the wx-users mailing list