Fix coverity warning.

- Dereferencing a pointer from realloc before checking if it's null.
This commit is contained in:
Ari Koivula 2015-05-05 09:40:24 +03:00
parent cf2a406aba
commit 17bdc82b5e

View file

@ -459,12 +459,13 @@ int encoder_state_init(encoder_state_t * const child_state, encoder_state_t * co
if (new_child) {
child_state->children = realloc(child_state->children, sizeof(encoder_state_t) * (2+child_count));
child_state->children[1+child_count].encoder_control = NULL;
if (!child_state->children) {
fprintf(stderr, "Failed to allocate memory for children...\n");
return 0;
}
child_state->children[1 + child_count].encoder_control = NULL;
//Fix children parent (since we changed the address), except for the last one which is not ready yet
{
int i, j;