Don't allocate structure twice.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 1 Dec 2008 09:45:49 +0000 (10:45 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 1 Dec 2008 16:47:24 +0000 (17:47 +0100)
This fixes Coverity #78

src/modules/rlm_policy/parse.c

index 7fd74b3..ae201ab 100644 (file)
@@ -1002,8 +1002,12 @@ static int parse_attribute_block(policy_lex_file_t *lexer,
        }
        memset(this, 0, sizeof(*this));
        this->item.type = POLICY_TYPE_ATTRIBUTE_LIST;
+       this->item.lineno = lexer->lineno;
+       this->where = where;
 
        token = policy_lex_file(lexer, 0, buffer, sizeof(buffer));
+       this->how = token;
+
        switch (token) {
        case POLICY_LEX_BEFORE_WHERE_EQUALS:
        case POLICY_LEX_AFTER_WHERE_EQUALS:
@@ -1030,14 +1034,6 @@ static int parse_attribute_block(policy_lex_file_t *lexer,
                return 0;       /* unknown */
        }
 
-       this = rad_malloc(sizeof(*this));
-       memset(this, 0, sizeof(*this));
-
-       this->item.type = POLICY_TYPE_ATTRIBUTE_LIST;
-       this->item.lineno = lexer->lineno;
-       this->where = where;
-       this->how = token;
-
        if (!parse_block(lexer, &(this->attributes))) {
                rlm_policy_free_item((policy_item_t *) this);
                return 0;