1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

io: Fix memory lifetime issue with input buffers

xmlParserInputBufferCreateMem must make a copy of the buffer.

This fixes a regression from 2.11 which could cause reads from freed
memory depending on the use case.

Undeprecate xmlParserInputBufferCreateStatic which can avoid copying
the whole buffer.
This commit is contained in:
Nick Wellnhofer
2023-12-12 23:51:32 +01:00
parent 0e4a11bb30
commit c2bbeed1fd
5 changed files with 70 additions and 31 deletions

View File

@@ -6719,7 +6719,8 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
htmlCtxtReset(ctxt);
input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE);
input = xmlParserInputBufferCreateStatic(buffer, size,
XML_CHAR_ENCODING_NONE);
if (input == NULL) {
htmlErrMemory(ctxt, NULL);
return(NULL);