Skip to content

Commit 3955b65

Browse files
Mykola Mokhnachfacebook-github-bot
authored andcommitted
Access xpathCtx properties after NULL-pointer verification is passed
Summary: It is possible that _xmlXPathNewContext_ returns NULL in case of internal failure and then we'll have some hardcore crash as a result. Closes facebookarchive#469 Differential Revision: D4474571 Pulled By: marekcirkos fbshipit-source-id: 9edd09d81d3b0097d06f86deb807c011bfe65ead
1 parent 04d1b34 commit 3955b65

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

WebDriverAgentLib/Utilities/FBXPath.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ + (xmlChar *)xmlCharPtrForInput:(const char *)input
167167
+ (xmlXPathObjectPtr)evaluate:(NSString *)xpathQuery document:(xmlDocPtr)doc
168168
{
169169
xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
170-
xpathCtx->node = doc->children;
171170
if (NULL == xpathCtx) {
172171
[FBLogger logFmt:@"Failed to invoke libxml2>xmlXPathNewContext for XPath query \"%@\"", xpathQuery];
173172
return NULL;
174173
}
174+
xpathCtx->node = doc->children;
175175

176176
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression([FBXPath xmlCharPtrForInput:[xpathQuery cStringUsingEncoding:NSUTF8StringEncoding]], xpathCtx);
177177
if (NULL == xpathObj) {

0 commit comments

Comments
 (0)