Error Domain=NSXMLParserErrorDomain Code=1 "(null)" on Linux when parsing larger amount of data
Opened this issue · 0 comments
maciejtrybilo commented
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.