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
e559ec2a
Commit
e559ec2a
authored
Dec 25, 2015
by
Sebastian Lackner
Committed by
Alexandre Julliard
Dec 29, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Align terminating null character in SysAllocStringByteLen.
Signed-off-by:
Sebastian Lackner
<
sebastian@fds-team.de
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4bfc49a7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
8 deletions
+35
-8
oleaut.c
dlls/oleaut32/oleaut.c
+6
-8
vartype.c
dlls/oleaut32/tests/vartype.c
+29
-0
No files found.
dlls/oleaut32/oleaut.c
View file @
e559ec2a
...
...
@@ -149,12 +149,9 @@ static bstr_t *alloc_bstr(size_t size)
if
(
cache_entry
)
{
if
(
WARN_ON
(
heap
))
{
size_t
tail
;
memset
(
ret
,
ARENA_INUSE_FILLER
,
FIELD_OFFSET
(
bstr_t
,
u
.
ptr
[
size
+
sizeof
(
WCHAR
)]));
tail
=
bstr_alloc_size
(
size
)
-
FIELD_OFFSET
(
bstr_t
,
u
.
ptr
[
size
+
sizeof
(
WCHAR
)]);
if
(
tail
)
memset
(
ret
->
u
.
ptr
+
size
+
sizeof
(
WCHAR
),
ARENA_TAIL_FILLER
,
tail
);
size_t
fill_size
=
(
FIELD_OFFSET
(
bstr_t
,
u
.
ptr
[
size
])
+
2
*
sizeof
(
WCHAR
)
-
1
)
&
~
(
sizeof
(
WCHAR
)
-
1
);
memset
(
ret
,
ARENA_INUSE_FILLER
,
fill_size
);
memset
((
char
*
)
ret
+
fill_size
,
ARENA_TAIL_FILLER
,
bstr_alloc_size
(
size
)
-
fill_size
);
}
ret
->
size
=
size
;
return
ret
;
...
...
@@ -418,10 +415,11 @@ BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len)
if
(
str
)
{
memcpy
(
bstr
->
u
.
ptr
,
str
,
len
);
bstr
->
u
.
ptr
[
len
]
=
bstr
->
u
.
ptr
[
len
+
1
]
=
0
;
bstr
->
u
.
ptr
[
len
]
=
0
;
}
else
{
memset
(
bstr
->
u
.
ptr
,
0
,
len
+
sizeof
(
WCHAR
)
);
memset
(
bstr
->
u
.
ptr
,
0
,
len
+
1
);
}
bstr
->
u
.
str
[(
len
+
sizeof
(
WCHAR
)
-
1
)
/
sizeof
(
WCHAR
)]
=
0
;
return
bstr
->
u
.
str
;
}
...
...
dlls/oleaut32/tests/vartype.c
View file @
e559ec2a
...
...
@@ -5444,7 +5444,9 @@ static void test_SysAllocStringByteLen(void)
{
const
OLECHAR
szTest
[
10
]
=
{
'T'
,
'e'
,
's'
,
't'
,
'\0'
};
const
CHAR
szTestA
[
6
]
=
{
'T'
,
'e'
,
's'
,
't'
,
'\0'
,
'?'
};
char
*
buf
;
BSTR
str
;
int
i
;
if
(
sizeof
(
void
*
)
==
4
)
/* not limited to 0x80000000 on Win64 */
{
...
...
@@ -5487,6 +5489,7 @@ static void test_SysAllocStringByteLen(void)
ok
(
bstr
->
dwLen
==
3
,
"Expected 3, got %d
\n
"
,
bstr
->
dwLen
);
ok
(
!
lstrcmpA
((
LPCSTR
)
bstr
->
szString
,
szTestTruncA
),
"String different
\n
"
);
ok
(
!
bstr
->
szString
[
2
],
"String not terminated
\n
"
);
SysFreeString
(
str
);
}
...
...
@@ -5500,6 +5503,32 @@ static void test_SysAllocStringByteLen(void)
ok
(
!
lstrcmpW
(
bstr
->
szString
,
szTest
),
"String different
\n
"
);
SysFreeString
(
str
);
}
/* Make sure terminating null is aligned properly */
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
1025
);
ok
(
buf
!=
NULL
,
"Expected non-NULL
\n
"
);
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
LPINTERNAL_BSTR
bstr
;
str
=
SysAllocStringByteLen
(
NULL
,
i
);
ok
(
str
!=
NULL
,
"Expected non-NULL
\n
"
);
bstr
=
Get
(
str
);
ok
(
bstr
->
dwLen
==
i
,
"Expected %d, got %d
\n
"
,
i
,
bstr
->
dwLen
);
ok
(
!
bstr
->
szString
[(
i
+
sizeof
(
WCHAR
)
-
1
)
/
sizeof
(
WCHAR
)],
"String not terminated
\n
"
);
SysFreeString
(
str
);
memset
(
buf
,
0xaa
,
1025
);
str
=
SysAllocStringByteLen
(
buf
,
i
);
ok
(
str
!=
NULL
,
"Expected non-NULL
\n
"
);
bstr
=
Get
(
str
);
ok
(
bstr
->
dwLen
==
i
,
"Expected %d, got %d
\n
"
,
i
,
bstr
->
dwLen
);
buf
[
i
]
=
0
;
ok
(
!
lstrcmpA
((
LPCSTR
)
bstr
->
szString
,
buf
),
"String different
\n
"
);
ok
(
!
bstr
->
szString
[(
i
+
sizeof
(
WCHAR
)
-
1
)
/
sizeof
(
WCHAR
)],
"String not terminated
\n
"
);
SysFreeString
(
str
);
}
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
}
static
void
test_SysReAllocString
(
void
)
...
...
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