Improve error handling
There are many cases where out-of-memory errors aren't reported. This can be detected with fuzz testing similar to #344 (closed). Typical issues are:
- Missing call to xmlErrMemory or similar functions.
- Overwriting ctxt->instate after a malloc failure.
- Functions that don't report memory errors.
- xmlGetProp
- xmlHashAddEntry
- __xmlRaiseError
- xmlFindCharEncodingHandler
Many low-level functions, for example in encoding.c
, report errors without a context argument. This will always invoke the thread-local error handler. Ultimately, it should be made possible to report all errors to a per-context error handler. This requires to return error codes which the caller has to handle properly.
Error handling in xmlregexp.c
is a total mess. Most callers don't handle errors properly.
Edited by Nick Wellnhofer