Initialize everything explicitly in parser
This commit is contained in:
10
lib/parser.c
10
lib/parser.c
@@ -55,6 +55,8 @@ static int parse_class(const char *input, int rem, class_t *out)
|
||||
if (used < rem && '^' == input[used]) {
|
||||
out->negated = true;
|
||||
++used;
|
||||
} else {
|
||||
out->negated = false;
|
||||
}
|
||||
|
||||
out->count = 0;
|
||||
@@ -139,6 +141,8 @@ static int parse_term(const char *input, int rem, term_t *out)
|
||||
default:
|
||||
out->quantifier = QUANTIFIER_NONE;
|
||||
}
|
||||
} else {
|
||||
out->quantifier = QUANTIFIER_NONE;
|
||||
}
|
||||
|
||||
return used;
|
||||
@@ -150,7 +154,7 @@ static int parse_sequence(const char *input, int rem, sequence_t *out)
|
||||
|
||||
out->len = 0;
|
||||
out->capacity = SEQUENCE_START_CAPACITY;
|
||||
out->contents = calloc(out->capacity, sizeof(term_t));
|
||||
out->contents = malloc(out->capacity * sizeof(term_t));
|
||||
if (NULL == out->contents)
|
||||
return -1;
|
||||
|
||||
@@ -186,13 +190,15 @@ int parse_regex(const char *input, int rem, regex_t *out)
|
||||
if (used < rem && '|' == input[used]) {
|
||||
++used;
|
||||
|
||||
out->alternative = calloc(1, sizeof(regex_t));
|
||||
out->alternative = malloc(sizeof(regex_t));
|
||||
if (NULL == out->alternative)
|
||||
return -1;
|
||||
result = parse_regex(input + used, rem - used, out->alternative);
|
||||
if (result < 0)
|
||||
return -1;
|
||||
used += result;
|
||||
} else {
|
||||
out->alternative = NULL;
|
||||
}
|
||||
|
||||
return used;
|
||||
|
||||
Reference in New Issue
Block a user