Fix allocation issue in FSA module
This commit is contained in:
@@ -33,7 +33,8 @@ int fsa_add_state(fsa_t *fsa)
|
||||
{
|
||||
if (fsa->count >= fsa->capacity) {
|
||||
fsa->capacity *= 2;
|
||||
fsa->states = realloc(fsa->states, fsa->capacity);
|
||||
fsa->states
|
||||
= realloc(fsa->states, fsa->capacity * sizeof(fsa_state_t));
|
||||
assert(NULL != fsa->states);
|
||||
}
|
||||
|
||||
@@ -56,7 +57,8 @@ void fsa_add_rule(fsa_t *fsa, int from, int to, int input)
|
||||
fsa_state_t *state = &fsa->states[from];
|
||||
if (state->count >= state->capacity) {
|
||||
state->capacity *= 2;
|
||||
state->rules = realloc(state->rules, state->capacity);
|
||||
state->rules
|
||||
= realloc(state->rules, state->capacity * sizeof(fsa_rule_t));
|
||||
assert(NULL != state->rules);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user