mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: fix potential mem corruption in _idFromUrl function
This patch fixes some potential memory corruptions in _idFromUrl function when name (url) is longer than 50 chars or is incorrectly terminated.
This commit is contained in:
parent
e0aa007659
commit
d7a3aa580a
1 changed files with 4 additions and 9 deletions
|
@ -272,24 +272,19 @@ _parseDashArray(SvgLoaderData* loader, const char *str, SvgDash* dash)
|
|||
|
||||
static string* _idFromUrl(const char* url)
|
||||
{
|
||||
char tmp[50];
|
||||
int i = 0;
|
||||
|
||||
url = _skipSpace(url, nullptr);
|
||||
if ((*url) == '(') {
|
||||
++url;
|
||||
url = _skipSpace(url, nullptr);
|
||||
}
|
||||
|
||||
if ((*url) == '\'') ++url;
|
||||
if ((*url) == '#') ++url;
|
||||
|
||||
while ((*url) != ')') {
|
||||
tmp[i++] = *url;
|
||||
++url;
|
||||
}
|
||||
tmp[i] = '\0';
|
||||
int i = 0;
|
||||
while (url[i] > ' ' && url[i] != ')' && url[i] != '\'') ++i;
|
||||
|
||||
return new string(tmp);
|
||||
return new string(url, i);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue