1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-23 01:52:48 +03:00

memory: Don't report OOM to stderr

This commit is contained in:
Nick Wellnhofer
2024-07-15 14:19:34 +02:00
parent 6be79014d7
commit f6170b489c

View File

@@ -103,16 +103,12 @@ xmlMemMalloc(size_t size)
xmlInitParser(); xmlInitParser();
if (size > (MAX_SIZE_T - RESERVE_SIZE)) { if (size > (MAX_SIZE_T - RESERVE_SIZE))
fprintf(stderr, "xmlMemMalloc: Unsigned overflow\n");
return(NULL); return(NULL);
}
p = (MEMHDR *) malloc(RESERVE_SIZE + size); p = (MEMHDR *) malloc(RESERVE_SIZE + size);
if (!p) { if (!p)
fprintf(stderr, "xmlMemMalloc: Out of memory\n");
return(NULL); return(NULL);
}
p->mh_tag = MEMTAG; p->mh_tag = MEMTAG;
p->mh_size = size; p->mh_size = size;
@@ -161,10 +157,8 @@ xmlMemRealloc(void *ptr, size_t size) {
xmlInitParser(); xmlInitParser();
if (size > (MAX_SIZE_T - RESERVE_SIZE)) { if (size > (MAX_SIZE_T - RESERVE_SIZE))
fprintf(stderr, "xmlMemRealloc: Unsigned overflow\n");
return(NULL); return(NULL);
}
p = CLIENT_2_HDR(ptr); p = CLIENT_2_HDR(ptr);
if (p->mh_tag != MEMTAG) { if (p->mh_tag != MEMTAG) {
@@ -177,7 +171,6 @@ xmlMemRealloc(void *ptr, size_t size) {
tmp = (MEMHDR *) realloc(p, RESERVE_SIZE + size); tmp = (MEMHDR *) realloc(p, RESERVE_SIZE + size);
if (!tmp) { if (!tmp) {
p->mh_tag = MEMTAG; p->mh_tag = MEMTAG;
fprintf(stderr, "xmlMemRealloc: Out of memory\n");
return(NULL); return(NULL);
} }
p = tmp; p = tmp;
@@ -260,16 +253,12 @@ xmlMemoryStrdup(const char *str) {
xmlInitParser(); xmlInitParser();
if (size > (MAX_SIZE_T - RESERVE_SIZE)) { if (size > (MAX_SIZE_T - RESERVE_SIZE))
fprintf(stderr, "xmlMemoryStrdup: Unsigned overflow\n");
return(NULL); return(NULL);
}
p = (MEMHDR *) malloc(RESERVE_SIZE + size); p = (MEMHDR *) malloc(RESERVE_SIZE + size);
if (!p) { if (!p)
fprintf(stderr, "xmlMemoryStrdup: Out of memory\n");
return(NULL); return(NULL);
}
p->mh_tag = MEMTAG; p->mh_tag = MEMTAG;
p->mh_size = size; p->mh_size = size;