Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e6107130
Commit
e6107130
authored
Feb 20, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Fix VariantCopy() for VT_RECORD variants.
parent
52a70451
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
48 deletions
+79
-48
vartest.c
dlls/oleaut32/tests/vartest.c
+44
-6
variant.c
dlls/oleaut32/variant.c
+35
-42
No files found.
dlls/oleaut32/tests/vartest.c
View file @
e6107130
...
...
@@ -102,6 +102,8 @@ typedef struct IRecordInfoImpl
IRecordInfo
IRecordInfo_iface
;
LONG
ref
;
unsigned
int
recordclear
;
unsigned
int
getsize
;
unsigned
int
recordcopy
;
struct
__tagBRECORD
*
rec
;
}
IRecordInfoImpl
;
...
...
@@ -152,15 +154,16 @@ static HRESULT WINAPI RecordInfo_RecordClear(IRecordInfo *iface, void *data)
{
IRecordInfoImpl
*
This
=
impl_from_IRecordInfo
(
iface
);
This
->
recordclear
++
;
ok
(
data
==
(
void
*
)
0xdeadbeef
,
"got %p
\n
"
,
data
);
This
->
rec
->
pvRecord
=
NULL
;
return
S_OK
;
}
static
HRESULT
WINAPI
RecordInfo_RecordCopy
(
IRecordInfo
*
iface
,
void
*
pvExisting
,
void
*
pvNew
)
static
HRESULT
WINAPI
RecordInfo_RecordCopy
(
IRecordInfo
*
iface
,
void
*
src
,
void
*
dest
)
{
ok
(
0
,
"unexpected call
\n
"
);
return
E_NOTIMPL
;
IRecordInfoImpl
*
This
=
impl_from_IRecordInfo
(
iface
);
This
->
recordcopy
++
;
ok
(
src
==
(
void
*
)
0xdeadbeef
,
"wrong src pointer %p
\n
"
,
src
);
return
S_OK
;
}
static
HRESULT
WINAPI
RecordInfo_GetGuid
(
IRecordInfo
*
iface
,
GUID
*
pguid
)
...
...
@@ -177,8 +180,10 @@ static HRESULT WINAPI RecordInfo_GetName(IRecordInfo *iface, BSTR *pbstrName)
static
HRESULT
WINAPI
RecordInfo_GetSize
(
IRecordInfo
*
iface
,
ULONG
*
size
)
{
ok
(
0
,
"unexpected call
\n
"
);
return
E_NOTIMPL
;
IRecordInfoImpl
*
This
=
impl_from_IRecordInfo
(
iface
);
This
->
getsize
++
;
*
size
=
0
;
return
S_OK
;
}
static
HRESULT
WINAPI
RecordInfo_GetTypeInfo
(
IRecordInfo
*
iface
,
ITypeInfo
**
ppTypeInfo
)
...
...
@@ -277,6 +282,10 @@ static IRecordInfoImpl *get_test_recordinfo(void)
rec
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
IRecordInfoImpl
));
rec
->
IRecordInfo_iface
.
lpVtbl
=
&
RecordInfoVtbl
;
rec
->
ref
=
1
;
rec
->
recordclear
=
0
;
rec
->
getsize
=
0
;
rec
->
recordcopy
=
0
;
return
rec
;
}
...
...
@@ -765,6 +774,8 @@ static void test_VariantClear(void)
static
void
test_VariantCopy
(
void
)
{
struct
__tagBRECORD
*
rec
;
IRecordInfoImpl
*
recinfo
;
VARIANTARG
vSrc
,
vDst
;
VARTYPE
vt
;
size_t
i
;
...
...
@@ -880,6 +891,33 @@ static void test_VariantCopy(void)
}
VariantClear
(
&
vDst
);
}
/* copy RECORD */
recinfo
=
get_test_recordinfo
();
memset
(
&
vDst
,
0
,
sizeof
(
vDst
));
V_VT
(
&
vDst
)
=
VT_EMPTY
;
V_VT
(
&
vSrc
)
=
VT_RECORD
;
rec
=
&
V_UNION
(
&
vSrc
,
brecVal
);
rec
->
pRecInfo
=
&
recinfo
->
IRecordInfo_iface
;
rec
->
pvRecord
=
(
void
*
)
0xdeadbeef
;
recinfo
->
recordclear
=
0
;
recinfo
->
recordcopy
=
0
;
recinfo
->
getsize
=
0
;
recinfo
->
rec
=
rec
;
hres
=
VariantCopy
(
&
vDst
,
&
vSrc
);
ok
(
hres
==
S_OK
,
"ret %08x
\n
"
,
hres
);
rec
=
&
V_UNION
(
&
vDst
,
brecVal
);
ok
(
rec
->
pvRecord
!=
(
void
*
)
0xdeadbeef
&&
rec
->
pvRecord
!=
NULL
,
"got %p
\n
"
,
rec
->
pvRecord
);
ok
(
rec
->
pRecInfo
==
&
recinfo
->
IRecordInfo_iface
,
"got %p
\n
"
,
rec
->
pRecInfo
);
ok
(
recinfo
->
getsize
==
1
,
"got %d
\n
"
,
recinfo
->
recordclear
);
ok
(
recinfo
->
recordcopy
==
1
,
"got %d
\n
"
,
recinfo
->
recordclear
);
VariantClear
(
&
vDst
);
VariantClear
(
&
vSrc
);
}
/* Determine if a vt is valid for VariantCopyInd() */
...
...
dlls/oleaut32/variant.c
View file @
e6107130
...
...
@@ -694,34 +694,32 @@ HRESULT WINAPI VariantClear(VARIANTARG* pVarg)
/******************************************************************************
* Copy an IRecordInfo object contained in a variant.
*/
static
HRESULT
VARIANT_CopyIRecordInfo
(
struct
__tagBRECORD
*
pBr
)
static
HRESULT
VARIANT_CopyIRecordInfo
(
VARIANT
*
dest
,
VARIANT
*
src
)
{
HRESULT
hres
=
S_OK
;
struct
__tagBRECORD
*
dest_rec
=
&
V_UNION
(
dest
,
brecVal
);
struct
__tagBRECORD
*
src_rec
=
&
V_UNION
(
src
,
brecVal
);
HRESULT
hr
=
S_OK
;
ULONG
size
;
if
(
pBr
->
pRecInfo
)
if
(
!
src_rec
->
pRecInfo
)
{
ULONG
ulSize
;
if
(
src_rec
->
pvRecord
)
return
E_INVALIDARG
;
return
S_OK
;
}
hres
=
IRecordInfo_GetSize
(
pBr
->
pRecInfo
,
&
ulSize
);
if
(
SUCCEEDED
(
hres
))
{
PVOID
pvRecord
=
HeapAlloc
(
GetProcessHeap
(),
0
,
ulSize
);
if
(
!
pvRecord
)
hres
=
E_OUTOFMEMORY
;
else
{
memcpy
(
pvRecord
,
pBr
->
pvRecord
,
ulSize
);
pBr
->
pvRecord
=
pvRecord
;
hr
=
IRecordInfo_GetSize
(
src_rec
->
pRecInfo
,
&
size
);
if
(
FAILED
(
hr
))
return
hr
;
hres
=
IRecordInfo_RecordCopy
(
pBr
->
pRecInfo
,
pvRecord
,
pvRecord
);
if
(
SUCCEEDED
(
hres
))
IRecordInfo_AddRef
(
pBr
->
pRecInfo
);
}
}
}
else
if
(
pBr
->
pvRecord
)
hres
=
E_INVALIDARG
;
return
hres
;
/* This could look cleaner if only RecordCreate() was used, but native doesn't use it.
Memory should be allocated in a same way as RecordCreate() does, so RecordDestroy()
could free it later. */
dest_rec
->
pvRecord
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
if
(
!
dest_rec
->
pvRecord
)
return
E_OUTOFMEMORY
;
dest_rec
->
pRecInfo
=
src_rec
->
pRecInfo
;
IRecordInfo_AddRef
(
src_rec
->
pRecInfo
);
return
IRecordInfo_RecordCopy
(
src_rec
->
pRecInfo
,
src_rec
->
pvRecord
,
dest_rec
->
pvRecord
);
}
/******************************************************************************
...
...
@@ -771,29 +769,25 @@ HRESULT WINAPI VariantCopy(VARIANTARG* pvargDest, VARIANTARG* pvargSrc)
if
(
!
V_ISBYREF
(
pvargSrc
))
{
if
(
V_ISARRAY
(
pvargSrc
))
{
if
(
V_ARRAY
(
pvargSrc
))
hres
=
SafeArrayCopy
(
V_ARRAY
(
pvargSrc
),
&
V_ARRAY
(
pvargDest
));
}
else
if
(
V_VT
(
pvargSrc
)
==
VT_BSTR
)
switch
(
V_VT
(
pvargSrc
))
{
case
VT_BSTR
:
V_BSTR
(
pvargDest
)
=
SysAllocStringByteLen
((
char
*
)
V_BSTR
(
pvargSrc
),
SysStringByteLen
(
V_BSTR
(
pvargSrc
)));
if
(
!
V_BSTR
(
pvargDest
))
{
TRACE
(
"!V_BSTR(pvargDest), SysAllocStringByteLen() failed to allocate %d bytes
\n
"
,
SysStringByteLen
(
V_BSTR
(
pvargSrc
)));
hres
=
E_OUTOFMEMORY
;
}
}
else
if
(
V_VT
(
pvargSrc
)
==
VT_RECORD
)
{
hres
=
VARIANT_CopyIRecordInfo
(
&
V_UNION
(
pvargDest
,
brecVal
));
}
else
if
(
V_VT
(
pvargSrc
)
==
VT_DISPATCH
||
V_VT
(
pvargSrc
)
==
VT_UNKNOWN
)
{
break
;
case
VT_RECORD
:
hres
=
VARIANT_CopyIRecordInfo
(
pvargDest
,
pvargSrc
);
break
;
case
VT_DISPATCH
:
case
VT_UNKNOWN
:
V_UNKNOWN
(
pvargDest
)
=
V_UNKNOWN
(
pvargSrc
);
if
(
V_UNKNOWN
(
pvargSrc
))
IUnknown_AddRef
(
V_UNKNOWN
(
pvargSrc
));
break
;
default:
if
(
V_ISARRAY
(
pvargSrc
))
hres
=
SafeArrayCopy
(
V_ARRAY
(
pvargSrc
),
&
V_ARRAY
(
pvargDest
));
}
}
}
...
...
@@ -912,8 +906,7 @@ HRESULT WINAPI VariantCopyInd(VARIANT* pvargDest, VARIANTARG* pvargSrc)
}
else
if
(
V_VT
(
pSrc
)
==
(
VT_RECORD
|
VT_BYREF
))
{
V_UNION
(
pvargDest
,
brecVal
)
=
V_UNION
(
pvargSrc
,
brecVal
);
hres
=
VARIANT_CopyIRecordInfo
(
&
V_UNION
(
pvargDest
,
brecVal
));
hres
=
VARIANT_CopyIRecordInfo
(
pvargDest
,
pvargSrc
);
}
else
if
(
V_VT
(
pSrc
)
==
(
VT_DISPATCH
|
VT_BYREF
)
||
V_VT
(
pSrc
)
==
(
VT_UNKNOWN
|
VT_BYREF
))
...
...
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