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
76c5590b
Commit
76c5590b
authored
Sep 22, 2004
by
Huw Davies
Committed by
Alexandre Julliard
Sep 22, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't trash the dst variant if we can't do the type conversion.
Add a test for this.
parent
634c7a49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
10 deletions
+39
-10
vartype.c
dlls/oleaut32/tests/vartype.c
+25
-0
variant.c
dlls/oleaut32/variant.c
+14
-10
No files found.
dlls/oleaut32/tests/vartype.c
View file @
76c5590b
...
...
@@ -5304,6 +5304,30 @@ static void test_NullByRef()
ok
(
hRes
==
DISP_E_BADVARTYPE
,
"VariantChangeTypeEx should return DISP_E_BADVARTYPE
\n
"
);
}
/* Dst Variant should remain unchanged if VariantChangeType cannot convert */
static
void
test_ChangeType_keep_dst
()
{
VARIANT
v1
,
v2
;
BSTR
bstr
;
WCHAR
testW
[]
=
{
't'
,
'e'
,
's'
,
't'
,
0
};
HRESULT
hres
;
bstr
=
SysAllocString
(
testW
);
VariantClear
(
&
v1
);
VariantClear
(
&
v2
);
V_VT
(
&
v1
)
=
VT_BSTR
;
V_BSTR
(
&
v1
)
=
bstr
;
hres
=
VariantChangeTypeEx
(
&
v1
,
&
v1
,
0
,
0
,
VT_INT
);
ok
(
hres
==
DISP_E_TYPEMISMATCH
,
"VariantChangeTypeEx returns %08lx
\n
"
,
hres
);
ok
(
V_VT
(
&
v1
)
==
VT_BSTR
&&
V_BSTR
(
&
v1
)
==
bstr
,
"VariantChangeTypeEx changed dst variant
\n
"
);
V_VT
(
&
v2
)
=
VT_INT
;
V_INT
(
&
v2
)
=
4
;
hres
=
VariantChangeTypeEx
(
&
v2
,
&
v1
,
0
,
0
,
VT_INT
);
ok
(
hres
==
DISP_E_TYPEMISMATCH
,
"VariantChangeTypeEx returns %08lx
\n
"
,
hres
);
ok
(
V_VT
(
&
v2
)
==
VT_INT
&&
V_INT
(
&
v2
)
==
4
,
"VariantChangeTypeEx changed dst variant
\n
"
);
SysFreeString
(
bstr
);
}
START_TEST
(
vartype
)
{
hOleaut32
=
LoadLibraryA
(
"oleaut32.dll"
);
...
...
@@ -5594,4 +5618,5 @@ START_TEST(vartype)
test_ClearCustData
();
test_NullByRef
();
test_ChangeType_keep_dst
();
}
dlls/oleaut32/variant.c
View file @
76c5590b
...
...
@@ -982,31 +982,35 @@ HRESULT WINAPI VariantChangeTypeEx(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
if
(
SUCCEEDED
(
res
))
{
VARIANTARG
vTmp
;
VARIANTARG
vTmp
,
vSrcDeref
;
if
(
V_VT
(
pvargSrc
)
&
VT_BYREF
&&
!
V_BYREF
(
pvargSrc
))
res
=
DISP_E_TYPEMISMATCH
;
else
{
V_VT
(
&
vTmp
)
=
VT_EMPTY
;
res
=
VariantCopyInd
(
&
vTmp
,
pvargSrc
);
V_VT
(
&
vSrcDeref
)
=
VT_EMPTY
;
VariantClear
(
&
vTmp
);
VariantClear
(
&
vSrcDeref
);
}
if
(
SUCCEEDED
(
res
))
{
res
=
VariantClear
(
pvargDest
);
res
=
VariantCopyInd
(
&
vSrcDeref
,
pvargSrc
);
if
(
SUCCEEDED
(
res
))
{
if
(
V_ISARRAY
(
&
v
Tmp
)
||
(
vt
&
VT_ARRAY
))
res
=
VARIANT_CoerceArray
(
pvargDest
,
&
vTmp
,
vt
);
if
(
V_ISARRAY
(
&
v
SrcDeref
)
||
(
vt
&
VT_ARRAY
))
res
=
VARIANT_CoerceArray
(
&
vTmp
,
&
vSrcDeref
,
vt
);
else
res
=
VARIANT_Coerce
(
pvargDest
,
lcid
,
wFlags
,
&
vTmp
,
vt
);
res
=
VARIANT_Coerce
(
&
vTmp
,
lcid
,
wFlags
,
&
vSrcDeref
,
vt
);
if
(
SUCCEEDED
(
res
))
V_VT
(
pvargDest
)
=
vt
;
if
(
SUCCEEDED
(
res
))
{
V_VT
(
&
vTmp
)
=
vt
;
VariantCopy
(
pvargDest
,
&
vTmp
);
}
VariantClear
(
&
vTmp
);
VariantClear
(
&
vSrcDeref
);
}
VariantClear
(
&
vTmp
);
}
}
}
...
...
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