mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-27 14:03:36 +03:00
string: Report malloc failures in xmlStrncat
Don't ignore malloc failures silently.
This commit is contained in:
parent
c37a9051b0
commit
2e5d273beb
@ -461,7 +461,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
ret = (xmlChar *) xmlRealloc(cur, (size_t) size + len + 1);
|
ret = (xmlChar *) xmlRealloc(cur, (size_t) size + len + 1);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
return(cur);
|
xmlFree(cur);
|
||||||
|
return(NULL);
|
||||||
}
|
}
|
||||||
memcpy(&ret[size], add, len);
|
memcpy(&ret[size], add, len);
|
||||||
ret[size + len] = 0;
|
ret[size + len] = 0;
|
||||||
@ -499,9 +500,8 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
|
|||||||
if ((size < 0) || (size > INT_MAX - len))
|
if ((size < 0) || (size > INT_MAX - len))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
ret = (xmlChar *) xmlMalloc((size_t) size + len + 1);
|
ret = (xmlChar *) xmlMalloc((size_t) size + len + 1);
|
||||||
if (ret == NULL) {
|
if (ret == NULL)
|
||||||
return(xmlStrndup(str1, size));
|
return(NULL);
|
||||||
}
|
|
||||||
memcpy(ret, str1, size);
|
memcpy(ret, str1, size);
|
||||||
memcpy(&ret[size], str2, len);
|
memcpy(&ret[size], str2, len);
|
||||||
ret[size + len] = 0;
|
ret[size + len] = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user