Skip to content
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

Error Domain=NSXMLParserErrorDomain Code=1 "(null)" on Linux when parsing larger amount of data #4851

Open
maciejtrybilo opened this issue Dec 1, 2023 · 0 comments

Comments

@maciejtrybilo
Copy link

When parsing an XML file from Data, it appears that libxml2 fails to allocate memory and XMLParser.parse() fails.

This happens then the XMLParser is initialised with larger data:

let xmlParser = XMLParser(data: data)
let parseResult = xmlParser.parse() // returns false and NSXMLParserErrorDomain Code=1 is set

There is a workaround currently to use an input stream:

let inputStream = InputStream(data: data)
let xmlParser = XMLParser(inputStream: data)
let parseResult = xmlParser.parse() // works fine

However, the issue occurs only on Linux and the size of the data required to trigger this isn't unreasonable IMO. I can trigger it with data of around 930,000 bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant