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
c9b8f5d2
Commit
c9b8f5d2
authored
Sep 02, 2010
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 03, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Fix invalid parameter handling for IXMLDOMElement::getElementsByTagName().
parent
fffa4881
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
27 deletions
+68
-27
domdoc.c
dlls/msxml3/domdoc.c
+3
-6
element.c
dlls/msxml3/element.c
+30
-21
domdoc.c
dlls/msxml3/tests/domdoc.c
+35
-0
No files found.
dlls/msxml3/domdoc.c
View file @
c9b8f5d2
...
...
@@ -1049,9 +1049,8 @@ static HRESULT WINAPI domdoc_get_documentElement(
IXMLDOMElement
**
DOMElement
)
{
domdoc
*
This
=
impl_from_IXMLDOMDocument3
(
iface
);
xmlDocPtr
xmldoc
=
NULL
;
xmlNodePtr
root
=
NULL
;
IXMLDOMNode
*
element_node
;
xmlNodePtr
root
;
HRESULT
hr
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
DOMElement
);
...
...
@@ -1061,16 +1060,14 @@ static HRESULT WINAPI domdoc_get_documentElement(
*
DOMElement
=
NULL
;
xmldoc
=
get_doc
(
This
);
root
=
xmlDocGetRootElement
(
xmldoc
);
root
=
xmlDocGetRootElement
(
get_doc
(
This
)
);
if
(
!
root
)
return
S_FALSE
;
element_node
=
create_node
(
root
);
if
(
!
element_node
)
return
S_FALSE
;
hr
=
IXMLDOMNode_QueryInterface
(
element_node
,
&
IID_IXMLDOMElement
,
(
LPVOID
*
)
DOMElement
);
hr
=
IXMLDOMNode_QueryInterface
(
element_node
,
&
IID_IXMLDOMElement
,
(
void
*
*
)
DOMElement
);
IXMLDOMNode_Release
(
element_node
);
return
hr
;
...
...
dlls/msxml3/element.c
View file @
c9b8f5d2
...
...
@@ -669,38 +669,47 @@ static HRESULT WINAPI domelem_removeAttributeNode(
static
HRESULT
WINAPI
domelem_getElementsByTagName
(
IXMLDOMElement
*
iface
,
BSTR
bstr
Name
,
IXMLDOMNodeList
**
resultList
)
BSTR
tag
Name
,
IXMLDOMNodeList
**
resultList
)
{
static
const
WCHAR
xpathformat
[]
=
{
'.'
,
'/'
,
'/'
,
'*'
,
'['
,
'l'
,
'o'
,
'c'
,
'a'
,
'l'
,
'-'
,
'n'
,
'a'
,
'm'
,
'e'
,
'('
,
')'
,
'='
,
'\''
,
'%'
,
's'
,
'\''
,
']'
,
0
};
domelem
*
This
=
impl_from_IXMLDOMElement
(
iface
);
LPWSTR
szPattern
;
xmlNodePtr
element
;
HRESULT
hr
;
TRACE
(
"(%p)->(%s %p)
\n
"
,
This
,
debugstr_w
(
bstr
Name
),
resultList
);
TRACE
(
"(%p)->(%s %p)
\n
"
,
This
,
debugstr_w
(
tag
Name
),
resultList
);
if
(
bstrName
[
0
]
==
'*'
&&
bstrName
[
1
]
==
0
)
if
(
!
tagName
||
!
resultList
)
return
E_INVALIDARG
;
if
(
!
(
element
=
get_element
(
This
)))
return
E_FAIL
;
if
(
tagName
[
0
]
==
'*'
&&
tagName
[
1
]
==
0
)
{
szPattern
=
heap_alloc
(
sizeof
(
WCHAR
)
*
5
);
szPattern
[
0
]
=
'.'
;
szPattern
[
1
]
=
szPattern
[
2
]
=
'/'
;
szPattern
[
3
]
=
'*'
;
szPattern
[
4
]
=
0
;
static
const
WCHAR
formatallW
[]
=
{
'/'
,
'/'
,
'*'
,
0
};
hr
=
queryresult_create
(
element
,
formatallW
,
resultList
);
}
else
{
szPattern
=
heap_alloc
(
sizeof
(
WCHAR
)
*
(
21
+
lstrlenW
(
bstrName
)
+
1
));
wsprintfW
(
szPattern
,
xpathformat
,
bstrName
);
}
TRACE
(
"%s
\n
"
,
debugstr_w
(
szPattern
));
static
const
WCHAR
xpathformat
[]
=
{
'/'
,
'/'
,
'*'
,
'['
,
'l'
,
'o'
,
'c'
,
'a'
,
'l'
,
'-'
,
'n'
,
'a'
,
'm'
,
'e'
,
'('
,
')'
,
'='
,
'\''
};
static
const
WCHAR
closeW
[]
=
{
'\''
,
']'
,
0
};
element
=
get_element
(
This
);
if
(
!
element
)
hr
=
E_FAIL
;
else
hr
=
queryresult_create
(
element
,
szPattern
,
resultList
);
heap_free
(
szPattern
);
LPWSTR
pattern
;
WCHAR
*
ptr
;
INT
length
;
length
=
lstrlenW
(
tagName
);
/* without two WCHARs from format specifier */
ptr
=
pattern
=
heap_alloc
(
sizeof
(
xpathformat
)
+
length
*
sizeof
(
WCHAR
)
+
sizeof
(
closeW
));
memcpy
(
ptr
,
xpathformat
,
sizeof
(
xpathformat
));
ptr
+=
sizeof
(
xpathformat
)
/
sizeof
(
WCHAR
);
memcpy
(
ptr
,
tagName
,
length
*
sizeof
(
WCHAR
));
ptr
+=
length
;
memcpy
(
ptr
,
closeW
,
sizeof
(
closeW
));
TRACE
(
"%s
\n
"
,
debugstr_w
(
pattern
));
hr
=
queryresult_create
(
element
,
pattern
,
resultList
);
heap_free
(
pattern
);
}
return
hr
;
}
...
...
dlls/msxml3/tests/domdoc.c
View file @
c9b8f5d2
...
...
@@ -2271,6 +2271,7 @@ static void test_getElementsByTagName(void)
{
IXMLDOMNodeList
*
node_list
;
IXMLDOMDocument
*
doc
;
IXMLDOMElement
*
elem
;
WCHAR
buff
[
100
];
VARIANT_BOOL
b
;
HRESULT
r
;
...
...
@@ -2346,6 +2347,40 @@ static void test_getElementsByTagName(void)
IXMLDOMNodeList_Release
(
node_list
);
SysFreeString
(
str
);
/* test for element */
r
=
IXMLDOMDocument_get_documentElement
(
doc
,
&
elem
);
ok
(
r
==
S_OK
,
"ret %08x
\n
"
,
r
);
str
=
SysAllocString
(
szstar
);
/* null arguments cases */
r
=
IXMLDOMElement_getElementsByTagName
(
elem
,
NULL
,
&
node_list
);
ok
(
r
==
E_INVALIDARG
,
"ret %08x
\n
"
,
r
);
r
=
IXMLDOMElement_getElementsByTagName
(
elem
,
str
,
NULL
);
ok
(
r
==
E_INVALIDARG
,
"ret %08x
\n
"
,
r
);
r
=
IXMLDOMElement_getElementsByTagName
(
elem
,
str
,
&
node_list
);
ok
(
r
==
S_OK
,
"ret %08x
\n
"
,
r
);
r
=
IXMLDOMNodeList_get_length
(
node_list
,
&
len
);
ok
(
r
==
S_OK
,
"ret %08x
\n
"
,
r
);
todo_wine
ok
(
len
==
5
,
"len %d
\n
"
,
len
);
IXMLDOMNodeList_Release
(
node_list
);
SysFreeString
(
str
);
/* broken query BSTR */
memcpy
(
&
buff
[
2
],
szstar
,
sizeof
(
szstar
));
/* just a big length */
*
(
DWORD
*
)
buff
=
0xf0f0
;
r
=
IXMLDOMElement_getElementsByTagName
(
elem
,
&
buff
[
2
],
&
node_list
);
ok
(
r
==
S_OK
,
"ret %08x
\n
"
,
r
);
r
=
IXMLDOMNodeList_get_length
(
node_list
,
&
len
);
ok
(
r
==
S_OK
,
"ret %08x
\n
"
,
r
);
todo_wine
ok
(
len
==
5
,
"len %d
\n
"
,
len
);
IXMLDOMNodeList_Release
(
node_list
);
IXMLDOMElement_Release
(
elem
);
IXMLDOMDocument_Release
(
doc
);
}
...
...
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