mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Merge pull request #109530 from bruvzg/svg_alloc
[TVG] Use heap for XML parser allocs.
This commit is contained in:
commit
eeb6ac01e8
3 changed files with 58 additions and 3 deletions
1
thirdparty/README.md
vendored
1
thirdparty/README.md
vendored
|
@ -1042,6 +1042,7 @@ Files extracted from upstream source:
|
||||||
Patches:
|
Patches:
|
||||||
|
|
||||||
- `0001-revert-tvglines-bezier-precision.patch` (GH-96658)
|
- `0001-revert-tvglines-bezier-precision.patch` (GH-96658)
|
||||||
|
- `0002-use-heap-alloc.patch` (GH-109530)
|
||||||
|
|
||||||
|
|
||||||
## tinyexr
|
## tinyexr
|
||||||
|
|
44
thirdparty/thorvg/patches/0002-use-heap-alloc.patch
vendored
Normal file
44
thirdparty/thorvg/patches/0002-use-heap-alloc.patch
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
|
||||||
|
index 81d5c098a2..4c0a0f53db 100644
|
||||||
|
--- a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
|
||||||
|
+++ b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
|
||||||
|
@@ -475,11 +475,14 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
|
if (!buf) return false;
|
||||||
|
|
||||||
|
end = buf + bufLength;
|
||||||
|
- key = (char*)alloca(end - buf + 1);
|
||||||
|
- val = (char*)alloca(end - buf + 1);
|
||||||
|
|
||||||
|
if (buf == end) return true;
|
||||||
|
|
||||||
|
+ char* key_buf = (char*)malloc(end - buf + 1);
|
||||||
|
+ char* val_buf = (char*)malloc(end - buf + 1);
|
||||||
|
+
|
||||||
|
+ key = key_buf;
|
||||||
|
+ val = val_buf;
|
||||||
|
do {
|
||||||
|
char* sep = (char*)strchr(buf, ':');
|
||||||
|
next = (char*)strchr(buf, ';');
|
||||||
|
@@ -487,7 +490,11 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
|
if (auto src = strstr(buf, "src")) {//src tag from css font-face contains extra semicolon
|
||||||
|
if (src < sep) {
|
||||||
|
if (next + 1 < end) next = (char*)strchr(next + 1, ';');
|
||||||
|
- else return true;
|
||||||
|
+ else {
|
||||||
|
+ free(key_buf);
|
||||||
|
+ free(val_buf);
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -534,6 +541,9 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
|
buf = next + 1;
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
+ free(key_buf);
|
||||||
|
+ free(val_buf);
|
||||||
|
+
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -475,11 +475,14 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
if (!buf) return false;
|
if (!buf) return false;
|
||||||
|
|
||||||
end = buf + bufLength;
|
end = buf + bufLength;
|
||||||
key = (char*)alloca(end - buf + 1);
|
|
||||||
val = (char*)alloca(end - buf + 1);
|
|
||||||
|
|
||||||
if (buf == end) return true;
|
if (buf == end) return true;
|
||||||
|
|
||||||
|
char* key_buf = (char*)malloc(end - buf + 1);
|
||||||
|
char* val_buf = (char*)malloc(end - buf + 1);
|
||||||
|
|
||||||
|
key = key_buf;
|
||||||
|
val = val_buf;
|
||||||
do {
|
do {
|
||||||
char* sep = (char*)strchr(buf, ':');
|
char* sep = (char*)strchr(buf, ':');
|
||||||
next = (char*)strchr(buf, ';');
|
next = (char*)strchr(buf, ';');
|
||||||
|
@ -487,7 +490,11 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
if (auto src = strstr(buf, "src")) {//src tag from css font-face contains extra semicolon
|
if (auto src = strstr(buf, "src")) {//src tag from css font-face contains extra semicolon
|
||||||
if (src < sep) {
|
if (src < sep) {
|
||||||
if (next + 1 < end) next = (char*)strchr(next + 1, ';');
|
if (next + 1 < end) next = (char*)strchr(next + 1, ';');
|
||||||
else return true;
|
else {
|
||||||
|
free(key_buf);
|
||||||
|
free(val_buf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,6 +541,9 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
|
||||||
buf = next + 1;
|
buf = next + 1;
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
|
free(key_buf);
|
||||||
|
free(val_buf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue