From: Daniel Veillard Date: Thu, 11 Jul 2013 15:41:22 +0800 Subject: Catch malloc error and exit accordingly As pointed privately by Bill Parker --- xmllint.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xmllint.c b/xmllint.c index c0196ab..4d464e4 100644 --- a/xmllint.c +++ b/xmllint.c @@ -3090,6 +3090,10 @@ static void usage(const char *name) { static void registerNode(xmlNodePtr node) { node->_private = malloc(sizeof(long)); + if (node->_private == NULL) { + fprintf(stderr, "Out of memory in xmllint:registerNode()\n"); + exit(XMLLINT_ERR_MEM); + } *(long*)node->_private = (long) 0x81726354; nbregister++; }