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
25c2e283
Commit
25c2e283
authored
Mar 20, 2009
by
Lei Zhang
Committed by
Alexandre Julliard
Mar 24, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Fix some corner cases in VarBstrCmp.
parent
68dba4ef
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
vartype.c
dlls/oleaut32/tests/vartype.c
+20
-0
vartype.c
dlls/oleaut32/vartype.c
+12
-4
No files found.
dlls/oleaut32/tests/vartype.c
View file @
25c2e283
...
...
@@ -4983,6 +4983,8 @@ static void test_VarBstrCmp(void)
static
const
WCHAR
s2
[]
=
{
'a'
,
0
,
'b'
};
static
const
char
sb1
[]
=
{
1
,
0
,
1
};
static
const
char
sb2
[]
=
{
1
,
0
,
2
};
static
const
char
sbchr0
[]
=
{
0
,
0
};
static
const
char
sbchr00
[]
=
{
0
,
0
,
0
};
BSTR
bstr
,
bstrempty
,
bstr2
;
CHECKPTR
(
VarBstrCmp
);
...
...
@@ -5021,6 +5023,15 @@ static void test_VarBstrCmp(void)
SysFreeString
(
bstr
);
bstr
=
SysAllocStringByteLen
(
sbchr0
,
sizeof
(
sbchr0
));
bstr2
=
SysAllocStringByteLen
(
sbchr0
,
sizeof
(
sbchr00
));
VARBSTRCMP
(
bstr
,
bstrempty
,
0
,
VARCMP_GT
);
VARBSTRCMP
(
bstrempty
,
bstr
,
0
,
VARCMP_LT
);
VARBSTRCMP
(
bstr2
,
bstrempty
,
0
,
VARCMP_GT
);
VARBSTRCMP
(
bstr2
,
bstr
,
0
,
VARCMP_EQ
);
SysFreeString
(
bstr2
);
SysFreeString
(
bstr
);
/* When (LCID == 0) it should be a binary comparison
* so these two strings could not match.
*/
...
...
@@ -5030,6 +5041,15 @@ static void test_VarBstrCmp(void)
VARBSTRCMP
(
bstr
,
bstr2
,
0
,
VARCMP_LT
);
SysFreeString
(
bstr2
);
SysFreeString
(
bstr
);
bstr
=
SysAllocStringByteLen
(
sbchr0
,
sizeof
(
sbchr0
));
bstr2
=
SysAllocStringByteLen
(
sbchr0
,
sizeof
(
sbchr00
));
VARBSTRCMP
(
bstr
,
bstrempty
,
0
,
VARCMP_GT
);
VARBSTRCMP
(
bstrempty
,
bstr
,
0
,
VARCMP_LT
);
VARBSTRCMP
(
bstr2
,
bstrempty
,
0
,
VARCMP_GT
);
VARBSTRCMP
(
bstr2
,
bstr
,
0
,
VARCMP_GT
);
SysFreeString
(
bstr2
);
SysFreeString
(
bstr
);
}
/* Get the internal representation of a BSTR */
...
...
dlls/oleaut32/vartype.c
View file @
25c2e283
...
...
@@ -6957,8 +6957,7 @@ HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFl
if
(
!
pbstrLeft
||
!*
pbstrLeft
)
{
if
(
!
pbstrRight
||
!*
pbstrRight
)
return
VARCMP_EQ
;
if
(
pbstrRight
&&
*
pbstrRight
)
return
VARCMP_LT
;
}
else
if
(
!
pbstrRight
||
!*
pbstrRight
)
...
...
@@ -6981,8 +6980,17 @@ HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFl
}
else
{
hres
=
CompareStringW
(
lcid
,
dwFlags
,
pbstrLeft
,
SysStringLen
(
pbstrLeft
),
pbstrRight
,
SysStringLen
(
pbstrRight
))
-
1
;
unsigned
int
lenLeft
=
SysStringLen
(
pbstrLeft
);
unsigned
int
lenRight
=
SysStringLen
(
pbstrRight
);
if
(
lenLeft
==
0
||
lenRight
==
0
)
{
if
(
lenLeft
==
0
&&
lenRight
==
0
)
return
VARCMP_EQ
;
return
lenLeft
<
lenRight
?
VARCMP_LT
:
VARCMP_GT
;
}
hres
=
CompareStringW
(
lcid
,
dwFlags
,
pbstrLeft
,
lenLeft
,
pbstrRight
,
lenRight
)
-
1
;
TRACE
(
"%d
\n
"
,
hres
);
return
hres
;
}
...
...
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