Die if we failed to allocate memory
authorAlan T. DeKok <aland@freeradius.org>
Mon, 1 Dec 2008 15:10:51 +0000 (16:10 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 1 Dec 2008 16:47:25 +0000 (17:47 +0100)
Closes Coverity #63

We don't need to check for "cs->section_tree" twice.  Just check for it
once, and if we can't allocate it, die.  Checking a second time is
pointless.

src/main/conffile.c

index 6fba0b7..ddc4a29 100644 (file)
@@ -517,11 +517,13 @@ static void cf_item_add(CONF_SECTION *cs, CONF_ITEM *ci)
 
                                if (!cs->section_tree) {
                                        cs->section_tree = rbtree_create(section_cmp, NULL, 0);
-                                       /* ignore any errors */
+                                       if (!cs->section_tree) {
+                                               radlog(L_ERR, "Out of memory");
+                                               _exit(1);
+                                       }
                                }
 
-                               if (cs->section_tree) {
-                                       rbtree_insert(cs->section_tree, cs_new);                                }
+                               rbtree_insert(cs->section_tree, cs_new);
 
                                /*
                                 *      Two names: find the named instance.