Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
5983fcfe
Commit
5983fcfe
authored
Aug 05, 2020
by
Piotr Caban
Committed by
Alexandre Julliard
Aug 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Return error on invalid character in mbstowcs.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
93bf951e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
mbcs.c
dlls/msvcrt/mbcs.c
+11
-4
string.c
dlls/msvcrt/tests/string.c
+5
-0
No files found.
dlls/msvcrt/mbcs.c
View file @
5983fcfe
...
...
@@ -2472,8 +2472,15 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
}
/* Ignore count parameter */
if
(
!
wcstr
)
return
MultiByteToWideChar
(
locinfo
->
lc_codepage
,
0
,
mbstr
,
-
1
,
NULL
,
0
)
-
1
;
if
(
!
wcstr
)
{
size
=
MultiByteToWideChar
(
locinfo
->
lc_codepage
,
MB_ERR_INVALID_CHARS
,
mbstr
,
-
1
,
NULL
,
0
);
if
(
!
size
)
{
*
MSVCRT__errno
()
=
MSVCRT_EILSEQ
;
return
-
1
;
}
return
size
-
1
;
}
for
(
i
=
0
,
size
=
0
;
i
<
count
;
i
++
)
{
if
(
mbstr
[
size
]
==
'\0'
)
...
...
@@ -2483,8 +2490,8 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
}
if
(
size
)
{
size
=
MultiByteToWideChar
(
locinfo
->
lc_codepage
,
0
,
mbstr
,
size
,
wcstr
,
count
);
size
=
MultiByteToWideChar
(
locinfo
->
lc_codepage
,
MB_ERR_INVALID_CHARS
,
mbstr
,
size
,
wcstr
,
count
);
if
(
!
size
)
{
if
(
count
)
wcstr
[
0
]
=
'\0'
;
*
MSVCRT__errno
()
=
MSVCRT_EILSEQ
;
...
...
dlls/msvcrt/tests/string.c
View file @
5983fcfe
...
...
@@ -2107,6 +2107,11 @@ static void test_mbstowcs(void)
ok
(
ret
==
0
,
"mbstowcs did not return 0, got %d
\n
"
,
(
int
)
ret
);
ok
(
!
memcmp
(
wOut
,
wEmpty
,
sizeof
(
wEmpty
)),
"wOut = %s
\n
"
,
wine_dbgstr_w
(
wOut
));
errno
=
0xdeadbeef
;
ret
=
mbstowcs
(
wOut
,
mHiragana
+
1
,
5
);
ok
(
ret
==
-
1
,
"mbstowcs did not return -1
\n
"
);
ok
(
errno
==
EILSEQ
,
"errno = %d
\n
"
,
errno
);
ret
=
wcstombs
(
mOut
,
wHiragana
,
6
);
ok
(
ret
==
4
,
"wcstombs did not return 4
\n
"
);
ok
(
!
memcmp
(
mOut
,
mHiragana
,
sizeof
(
mHiragana
)),
"mOut = %s
\n
"
,
mOut
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment