-
Notifications
You must be signed in to change notification settings - Fork 1.2k
_CFXMLInterface: account for possible nullptr return
#5082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@swift-ci please test |
|
CC: @jmschonfeld |
| CFStringRef resultString = __CFSwiftXMLParserBridgeCF.CFStringCreateWithCString(NULL, (const char*)result, kCFStringEncodingUTF8); | ||
| CFStringRef resultString = NULL; | ||
| if (result) { | ||
| __CFSwiftXMLParserBridgeCF.CFStringCreateWithCString(NULL, (const char*)result, kCFStringEncodingUTF8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - inconsistent spacing in the file.
Is xmlFree(NULL) ok to call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, AFAIK, xmlFree behaves as free, where nullptr as an argument is well defined.
|
@swift-ci please test Windows platform |
`xmlSplitQName2` may return `nullptr` for the result, which when passed to `CFStringCreateWithCString` would attempt to perform `strlen(nullptr)` which is ill-defined. When updating libxml2 on Windows, we would perform an invalid memory access due to the `strlen` invocation inside `CFStringCreateWithCString`. Protect against this case, returning `NULL` instead.
|
@swift-ci please test |
|
@swift-ci please test windows platform |
|
Any update |
|
Not pushing forward on this for the time being as the motivation behind this was behavioural changes in libxml2 2.13.x which has ABI breakages that are difficult to address. |
xmlSplitQName2may returnnullptrfor the result, which when passed toCFStringCreateWithCStringwould attempt to performstrlen(nullptr)which is ill-defined. When updating libxml2 on Windows, we would perform an invalid memory access due to thestrleninvocation insideCFStringCreateWithCString. Protect against this case, returningNULLinstead.