mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
more memory related code cleanups. Daniel
* HTMLparser.c parser.c relaxng.c xmlschemas.c: more memory related code cleanups. Daniel
This commit is contained in:
15
HTMLparser.c
15
HTMLparser.c
@@ -1703,12 +1703,15 @@ static const htmlEntityDesc html40EntitiesTable[] = {
|
||||
* Macro used to grow the current buffer.
|
||||
*/
|
||||
#define growBuffer(buffer) { \
|
||||
xmlChar *tmp; \
|
||||
buffer##_size *= 2; \
|
||||
buffer = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
|
||||
if (buffer == NULL) { \
|
||||
tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
|
||||
if (tmp == NULL) { \
|
||||
htmlErrMemory(ctxt, "growing buffer\n"); \
|
||||
xmlFree(buffer); \
|
||||
return(NULL); \
|
||||
} \
|
||||
buffer = tmp; \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2849,13 +2852,17 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
|
||||
((cur != '>') ||
|
||||
(r != '-') || (q != '-'))) {
|
||||
if (len + 5 >= size) {
|
||||
xmlChar *tmp;
|
||||
|
||||
size *= 2;
|
||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||
if (buf == NULL) {
|
||||
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||
if (tmp == NULL) {
|
||||
xmlFree(buf);
|
||||
htmlErrMemory(ctxt, "growing buffer failed\n");
|
||||
ctxt->instate = state;
|
||||
return;
|
||||
}
|
||||
buf = tmp;
|
||||
}
|
||||
COPY_BUF(ql,buf,len,q);
|
||||
q = r;
|
||||
|
Reference in New Issue
Block a user