[1/4] webservices: Fix use of month as array index.

Hans Leidekker hans at codeweavers.com
Wed Feb 15 07:17:09 CST 2017


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/tests/writer.c | 4 ++++
 dlls/webservices/writer.c       | 5 ++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index 039de556af..be6504ddc8 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -2716,6 +2716,10 @@ static void test_datetime(void)
         { 0x701ce51ced5d800, WS_DATETIME_FORMAT_LOCAL, S_OK, "<t>1601-01-01T07:00:00+00:00</t>",
           "<t>1601-01-01T01:00:00-06:00</t>" /* win7 */ },
         { 0, WS_DATETIME_FORMAT_NONE + 1, WS_E_INVALID_FORMAT },
+        { 0x38a080649c000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>0004-02-28T00:00:00Z</t>" },
+        { 0x38ad130b38000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>0004-02-29T00:00:00Z</t>" },
+        { 0x8c1505f0e438000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>2000-02-29T00:00:00Z</t>" },
+        { 0x8d46035e7870000, WS_DATETIME_FORMAT_UTC, S_OK, "<t>2017-03-01T00:00:00Z</t>" },
     };
     HRESULT hr;
     WS_XML_WRITER *writer;
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index f01a5a0929..4415a2465c 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -1203,7 +1203,7 @@ static inline int year_size( int year )
 static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
 {
     static const char fmt[] = "%04u-%02u-%02uT%02u:%02u:%02u";
-    int day, hour, min, sec, sec_frac, month = 1, year = 1, tz_hour;
+    int day, hour, min, sec, sec_frac, month = 0, year = 1, tz_hour;
     unsigned __int64 ticks, day_ticks;
     ULONG len;
 
@@ -1235,9 +1235,8 @@ static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
         day -= month_days[leap_year( year )][month];
         month++;
     }
-    day++;
 
-    len = sprintf( (char *)buf, fmt, year, month, day, hour, min, sec );
+    len = sprintf( (char *)buf, fmt, year, month + 1, day + 1, hour, min, sec );
     if (sec_frac)
     {
         static const char fmt_frac[] = ".%07u";
-- 
2.11.0




More information about the wine-patches mailing list