Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
ce61b254
Commit
ce61b254
authored
Apr 18, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Apr 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Only check the buffer pointer in FormatMessageA if buffer allocation is requested.
parent
8b28efae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
2 deletions
+83
-2
format_msg.c
dlls/kernel32/format_msg.c
+1
-1
format_msg.c
dlls/kernel32/tests/format_msg.c
+82
-1
No files found.
dlls/kernel32/format_msg.c
View file @
ce61b254
...
@@ -434,7 +434,7 @@ DWORD WINAPI FormatMessageA(
...
@@ -434,7 +434,7 @@ DWORD WINAPI FormatMessageA(
&&
((
dwFlags
&
FORMAT_MESSAGE_FROM_SYSTEM
)
&&
((
dwFlags
&
FORMAT_MESSAGE_FROM_SYSTEM
)
||
(
dwFlags
&
FORMAT_MESSAGE_FROM_HMODULE
)))
return
0
;
||
(
dwFlags
&
FORMAT_MESSAGE_FROM_HMODULE
)))
return
0
;
if
(
!
lpBuffer
)
if
(
(
dwFlags
&
FORMAT_MESSAGE_ALLOCATE_BUFFER
)
&&
!
lpBuffer
)
{
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
0
;
return
0
;
...
...
dlls/kernel32/tests/format_msg.c
View file @
ce61b254
...
@@ -734,6 +734,32 @@ static void test_message_null_buffer(void)
...
@@ -734,6 +734,32 @@ static void test_message_null_buffer(void)
{
{
DWORD
ret
,
error
;
DWORD
ret
,
error
;
/* Without FORMAT_MESSAGE_ALLOCATE_BUFFER, only the specified buffer size is checked. */
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageA returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INSUFFICIENT_BUFFER
||
error
==
ERROR_INVALID_PARAMETER
,
/* win9x */
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
1
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageA returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INSUFFICIENT_BUFFER
||
error
==
ERROR_INVALID_PARAMETER
,
/* win9x */
"last error %u
\n
"
,
error
);
if
(
0
)
/* crashes on Windows */
{
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
256
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageA returned %u
\n
"
,
ret
);
trace
(
"last error %u
\n
"
,
error
);
}
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
error
=
GetLastError
();
error
=
GetLastError
();
...
@@ -743,7 +769,28 @@ static void test_message_null_buffer(void)
...
@@ -743,7 +769,28 @@ static void test_message_null_buffer(void)
"last error %u
\n
"
,
error
);
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
1
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageA returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_NOT_ENOUGH_MEMORY
||
error
==
ERROR_INVALID_PARAMETER
,
/* win9x */
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
256
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageA returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_NOT_ENOUGH_MEMORY
||
error
==
ERROR_INVALID_PARAMETER
,
/* win9x */
"last error %u
\n
"
,
error
);
}
static
void
test_message_null_buffer_wide
(
void
)
{
DWORD
ret
,
error
;
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
error
=
GetLastError
();
error
=
GetLastError
();
if
(
!
ret
&&
error
==
ERROR_CALL_NOT_IMPLEMENTED
)
if
(
!
ret
&&
error
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
{
...
@@ -751,6 +798,39 @@ static void test_message_null_buffer(void)
...
@@ -751,6 +798,39 @@ static void test_message_null_buffer(void)
return
;
return
;
}
}
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
1
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
0
,
0
,
NULL
,
256
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
0
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
1
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_ALLOCATE_BUFFER
,
NULL
,
0
,
0
,
NULL
,
256
,
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
!
ret
,
"FormatMessageW returned %u
\n
"
,
ret
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"last error %u
\n
"
,
error
);
}
}
...
@@ -822,5 +902,6 @@ START_TEST(format_msg)
...
@@ -822,5 +902,6 @@ START_TEST(format_msg)
test_message_insufficient_buffer
();
test_message_insufficient_buffer
();
test_message_insufficient_buffer_wide
();
test_message_insufficient_buffer_wide
();
test_message_null_buffer
();
test_message_null_buffer
();
test_message_null_buffer_wide
();
test_message_from_hmodule
();
test_message_from_hmodule
();
}
}
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