diff options
author | Frank Schreiner <schreiner@suse.de> | 2022-04-01 15:51:57 +0300 |
---|---|---|
committer | amatej <matej.ales@seznam.cz> | 2022-04-04 10:19:59 +0300 |
commit | 7a8da8b08364770476e9035c806bc700a3438853 (patch) | |
tree | 6b818931c1a4f28eaf987c734e8bb0367e195cb6 | |
parent | e53188f86f4dfad46f5b81d6931cbaec19e44ea2 (diff) |
fix memory allocation in unescape_ampersand_from_values
-rw-r--r-- | src/xml_parser.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/xml_parser.c b/src/xml_parser.c index 37203ef..6ae83dd 100644 --- a/src/xml_parser.c +++ b/src/xml_parser.c @@ -309,8 +309,8 @@ unescape_ampersand_from_values(const xmlChar **attr, gboolean *allocation_needed // we know which keys we want (they don't contain &) so // we don't have to check those. size_t nattr; - for (nattr = 1; attr[nattr]; nattr+=2) { - if (strchr((char *)attr[nattr], '&')) { + for (nattr = 0; attr[nattr]; nattr+=2) { + if (strchr((char *)attr[nattr+1], '&')) { *allocation_needed = TRUE; } } @@ -319,7 +319,7 @@ unescape_ampersand_from_values(const xmlChar **attr, gboolean *allocation_needed return attr; } - char **attr_copy = g_malloc0(sizeof(char *) * (nattr - 1)); + char **attr_copy = g_malloc0(sizeof(char *) * (nattr + 1)); if (attr_copy) { for (nattr = 0; attr[nattr]; nattr++) { if (strchr((char *)attr[nattr], '&')) { |