From a52e8bc7f279b3932f9ac5c241207b4509c9bd99 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 12 Mar 2010 17:19:25 -0500 Subject: Check for realloc() failures. --- dimension/lexer.l | 3 +++ dimension/parse.c | 2 ++ 2 files changed, 5 insertions(+) (limited to 'dimension') diff --git a/dimension/lexer.l b/dimension/lexer.l index 4beeee7..d198b62 100644 --- a/dimension/lexer.l +++ b/dimension/lexer.l @@ -97,6 +97,9 @@ if (string_length + len + 1 >= string_length) { \ string_extent = 2*(string_length + len + 1); \ lvalp->value = realloc(lvalp->value, string_extent); \ + if (!lvalp->value) \ + dmnsn_error(DMNSN_SEVERITY_HIGH, \ + "Couldn't allocate space for token value."); \ } \ \ strncpy(lvalp->value + string_length, str, len + 1); \ diff --git a/dimension/parse.c b/dimension/parse.c index 7897b86..9f4a783 100644 --- a/dimension/parse.c +++ b/dimension/parse.c @@ -134,6 +134,8 @@ dmnsn_patricia_insert(dmnsn_patricia_trie *trie, /* Split the tree */ dmnsn_patricia_trie *copy = dmnsn_new_patricia_trie(); copy->prefix = realloc(copy->prefix, strlen(prefix) + 1); + if (!trie->prefix) + dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't allocate room for prefix."); strcpy(copy->prefix, prefix); *prefix = '\0'; -- cgit v1.2.3