Jacek Caban : scrobj: Use ReadValueChunk to read script body.
Alexandre Julliard
julliard at winehq.org
Thu Sep 26 15:51:19 CDT 2019
Module: wine
Branch: master
Commit: a8af3543745010dd3ff41a16fee0212d571d3118
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a8af3543745010dd3ff41a16fee0212d571d3118
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Sep 26 13:57:38 2019 +0200
scrobj: Use ReadValueChunk to read script body.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/scrobj/scrobj.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/scrobj/scrobj.c b/dlls/scrobj/scrobj.c
index e9262c53dc..944bff0de9 100644
--- a/dlls/scrobj/scrobj.c
+++ b/dlls/scrobj/scrobj.c
@@ -1583,8 +1583,13 @@ static HRESULT parse_scriptlet_public(struct scriptlet_factory *factory)
static HRESULT parse_scriptlet_script(struct scriptlet_factory *factory, struct scriptlet_script *script)
{
XmlNodeType node_type;
+ size_t buf_size, size;
+ WCHAR *new_body;
+ DWORD read;
HRESULT hres;
+ TRACE("\n");
+
for (;;)
{
hres = IXmlReader_MoveToNextAttribute(factory->xml_reader);
@@ -1621,9 +1626,26 @@ static HRESULT parse_scriptlet_script(struct scriptlet_factory *factory, struct
return E_FAIL;
}
- hres = read_xml_value(factory, &script->body);
- if (FAILED(hres)) return hres;
+ if (!(script->body = heap_alloc((buf_size = 1024) * sizeof(WCHAR)))) return E_OUTOFMEMORY;
+ size = 0;
+
+ for (;;)
+ {
+ read = 0;
+ hres = IXmlReader_ReadValueChunk(factory->xml_reader, script->body + size, buf_size - size - 1, &read);
+ if (FAILED(hres)) return hres;
+ size += read;
+ if (hres == S_FALSE) break;
+ if (size + 1 == buf_size)
+ {
+ if (!(new_body = heap_realloc(script->body, (buf_size *= 2) * sizeof(WCHAR)))) return E_OUTOFMEMORY;
+ script->body = new_body;
+ }
+ }
+ script->body[size++] = 0;
+ if (size != buf_size) script->body = heap_realloc(script->body, size * sizeof(WCHAR));
+ TRACE("body %s\n", debugstr_w(script->body));
return expect_end_element(factory);
}
More information about the wine-cvs
mailing list