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
9a5098bb
Commit
9a5098bb
authored
Jun 01, 2010
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jun 01, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Copy bytes instead of WCHARs in VarBstrCat.
parent
9ad9012f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
7 deletions
+50
-7
vartype.c
dlls/oleaut32/tests/vartype.c
+44
-2
vartype.c
dlls/oleaut32/vartype.c
+6
-5
No files found.
dlls/oleaut32/tests/vartype.c
View file @
9a5098bb
...
@@ -5486,12 +5486,17 @@ static void test_VarBstrCat(void)
...
@@ -5486,12 +5486,17 @@ static void test_VarBstrCat(void)
static
const
WCHAR
s1
[]
=
{
'a'
,
0
};
static
const
WCHAR
s1
[]
=
{
'a'
,
0
};
static
const
WCHAR
s2
[]
=
{
'b'
,
0
};
static
const
WCHAR
s2
[]
=
{
'b'
,
0
};
static
const
WCHAR
s1s2
[]
=
{
'a'
,
0
,
'b'
,
0
};
static
const
WCHAR
s1s2
[]
=
{
'a'
,
0
,
'b'
,
0
};
static
const
char
str1A
[]
=
"Have "
;
static
const
char
str2A
[]
=
"A Cigar"
;
HRESULT
ret
;
HRESULT
ret
;
BSTR
str1
,
str2
,
res
;
BSTR
str1
,
str2
,
res
;
UINT
len
;
/* Crash
if
(
0
)
{
/* Crash */
ret
=
VarBstrCat
(
NULL
,
NULL
,
NULL
);
ret
=
VarBstrCat
(
NULL
,
NULL
,
NULL
);
*/
}
/* Concatenation of two NULL strings works */
/* Concatenation of two NULL strings works */
ret
=
VarBstrCat
(
NULL
,
NULL
,
&
res
);
ret
=
VarBstrCat
(
NULL
,
NULL
,
&
res
);
...
@@ -5543,6 +5548,43 @@ static void test_VarBstrCat(void)
...
@@ -5543,6 +5548,43 @@ static void test_VarBstrCat(void)
SysFreeString
(
str2
);
SysFreeString
(
str2
);
SysFreeString
(
str1
);
SysFreeString
(
str1
);
/* Concatenation of ansi BSTRs, both odd byte count not including termination */
str1
=
SysAllocStringByteLen
(
str1A
,
sizeof
(
str1A
)
-
1
);
str2
=
SysAllocStringByteLen
(
str2A
,
sizeof
(
str2A
)
-
1
);
len
=
SysStringLen
(
str1
);
ok
(
len
==
(
sizeof
(
str1A
)
-
1
)
/
sizeof
(
WCHAR
),
"got length %u
\n
"
,
len
);
len
=
SysStringLen
(
str2
);
ok
(
len
==
(
sizeof
(
str2A
)
-
1
)
/
sizeof
(
WCHAR
),
"got length %u
\n
"
,
len
);
ret
=
VarBstrCat
(
str1
,
str2
,
&
res
);
ok
(
ret
==
S_OK
,
"VarBstrCat failed: %08x
\n
"
,
ret
);
ok
(
res
!=
NULL
,
"Expected a string
\n
"
);
len
=
(
sizeof
(
str1A
)
+
sizeof
(
str2A
)
-
2
)
/
sizeof
(
WCHAR
);
ok
(
SysStringLen
(
res
)
==
len
,
"got %d, expected %u
\n
"
,
SysStringLen
(
res
),
len
);
ok
(
!
memcmp
(
res
,
"Have A Cigar"
,
sizeof
(
str1A
)
+
sizeof
(
str2A
)
-
1
),
"got (%s)
\n
"
,
(
char
*
)
res
);
SysFreeString
(
res
);
SysFreeString
(
str2
);
SysFreeString
(
str1
);
/* Concatenation of ansi BSTRs, both 1 byte length not including termination */
str1
=
SysAllocStringByteLen
(
str1A
,
1
);
str2
=
SysAllocStringByteLen
(
str2A
,
1
);
len
=
SysStringLen
(
str1
);
ok
(
len
==
0
,
"got length %u
\n
"
,
len
);
len
=
SysStringLen
(
str2
);
ok
(
len
==
0
,
"got length %u
\n
"
,
len
);
ret
=
VarBstrCat
(
str1
,
str2
,
&
res
);
ok
(
ret
==
S_OK
,
"VarBstrCat failed: %08x
\n
"
,
ret
);
ok
(
res
!=
NULL
,
"Expected a string
\n
"
);
ok
(
SysStringLen
(
res
)
==
1
,
"got %d, expected 1
\n
"
,
SysStringLen
(
res
));
ok
(
!
memcmp
(
res
,
"HA"
,
2
),
"got (%s)
\n
"
,
(
char
*
)
res
);
SysFreeString
(
res
);
SysFreeString
(
str2
);
SysFreeString
(
str1
);
}
}
/* IUnknown */
/* IUnknown */
...
...
dlls/oleaut32/vartype.c
View file @
9a5098bb
...
@@ -6932,20 +6932,21 @@ HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
...
@@ -6932,20 +6932,21 @@ HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
if
(
!
pbstrOut
)
if
(
!
pbstrOut
)
return
E_INVALIDARG
;
return
E_INVALIDARG
;
lenLeft
=
pbstrLeft
?
SysStringLen
(
pbstrLeft
)
:
0
;
/* use byte length here to properly handle ansi-allocated BSTRs */
lenRight
=
pbstrRight
?
SysStringLen
(
pbstrRight
)
:
0
;
lenLeft
=
pbstrLeft
?
SysStringByteLen
(
pbstrLeft
)
:
0
;
lenRight
=
pbstrRight
?
SysStringByteLen
(
pbstrRight
)
:
0
;
*
pbstrOut
=
SysAllocStringLen
(
NULL
,
lenLeft
+
lenRight
);
*
pbstrOut
=
SysAllocString
Byte
Len
(
NULL
,
lenLeft
+
lenRight
);
if
(
!*
pbstrOut
)
if
(
!*
pbstrOut
)
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
(
*
pbstrOut
)[
0
]
=
'\0'
;
(
*
pbstrOut
)[
0
]
=
'\0'
;
if
(
pbstrLeft
)
if
(
pbstrLeft
)
memcpy
(
*
pbstrOut
,
pbstrLeft
,
lenLeft
*
sizeof
(
WCHAR
)
);
memcpy
(
*
pbstrOut
,
pbstrLeft
,
lenLeft
);
if
(
pbstrRight
)
if
(
pbstrRight
)
memcpy
(
*
pbstrOut
+
lenLeft
,
pbstrRight
,
lenRight
*
sizeof
(
WCHAR
)
);
memcpy
(
(
CHAR
*
)
*
pbstrOut
+
lenLeft
,
pbstrRight
,
lenRight
);
TRACE
(
"%s
\n
"
,
debugstr_wn
(
*
pbstrOut
,
SysStringLen
(
*
pbstrOut
)));
TRACE
(
"%s
\n
"
,
debugstr_wn
(
*
pbstrOut
,
SysStringLen
(
*
pbstrOut
)));
return
S_OK
;
return
S_OK
;
...
...
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