Module: wine Branch: master Commit: 18420826aae58b25bdace5dc52ee7c6568e46aa8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=18420826aae58b25bdace5dc52...
Author: Sebastian Lackner sebastian@fds-team.de Date: Wed Sep 7 19:04:48 2016 +0200
jscript: Do not include terminating \0 in result returned by Date_toLocale{Date,Time}String.
Signed-off-by: Sebastian Lackner sebastian@fds-team.de Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/date.c | 4 ++-- dlls/jscript/tests/api.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c index b35d812..b6997ab 100644 --- a/dlls/jscript/date.c +++ b/dlls/jscript/date.c @@ -925,7 +925,7 @@ static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD WCHAR *ptr;
len = GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, NULL, 0); - date_str = jsstr_alloc_buf(len, &ptr); + date_str = jsstr_alloc_buf(len-1, &ptr); if(!date_str) return E_OUTOFMEMORY; GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, ptr, len); @@ -964,7 +964,7 @@ static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD WCHAR *ptr;
len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0); - date_str = jsstr_alloc_buf(len, &ptr); + date_str = jsstr_alloc_buf(len-1, &ptr); if(!date_str) return E_OUTOFMEMORY; GetTimeFormatW(ctx->lcid, 0, &st, NULL, ptr, len); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 1ca974d..c7f2bcd 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -2130,6 +2130,11 @@ ok(Date.parse("Tue, 22 Mar 2016 09:57:55 -0300") === Date.parse("Tue, 22 Mar 201 ok(Date.parse("Tue, 22 Mar 2016 09:57:55 +0400") === Date.parse("Tue, 22 Mar 2016 09:57:55 UTC+0400"), "Date.parse("Tue, 22 Mar 2016 09:57:55 +0400") = " + Date.parse("Tue, 22 Mar 2016 09:57:55 +0400"));
+tmp = (new Date()).toLocaleDateString(); +ok(tmp.charCodeAt(tmp.length-1) != 0, "invalid null byte"); +tmp = (new Date()).toLocaleTimeString(); +ok(tmp.charCodeAt(tmp.length-1) != 0, "invalid null byte"); + ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI)); ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI); Math.PI = "test";