Debian Codegraph @

thirdparty/thorvg/patches/0002-use-heap-alloc.patch

raw
1 diff --git a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
2 index 81d5c098a2..4c0a0f53db 100644
3 --- a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
4 +++ b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
5 @@ -475,11 +475,14 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
6 if (!buf) return false;
7
8 end = buf + bufLength;
9 - key = (char*)alloca(end - buf + 1);
10 - val = (char*)alloca(end - buf + 1);
11
12 if (buf == end) return true;
13
14 + char* key_buf = (char*)malloc(end - buf + 1);
15 + char* val_buf = (char*)malloc(end - buf + 1);
16 +
17 + key = key_buf;
18 + val = val_buf;
19 do {
20 char* sep = (char*)strchr(buf, ':');
21 next = (char*)strchr(buf, ';');
22 @@ -487,7 +490,11 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
23 if (auto src = strstr(buf, "src")) {//src tag from css font-face contains extra semicolon
24 if (src < sep) {
25 if (next + 1 < end) next = (char*)strchr(next + 1, ';');
26 - else return true;
27 + else {
28 + free(key_buf);
29 + free(val_buf);
30 + return true;
31 + }
32 }
33 }
34
35 @@ -534,6 +541,9 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
36 buf = next + 1;
37 } while (true);
38
39 + free(key_buf);
40 + free(val_buf);
41 +
42 return true;
43 }
44