servo: NULL pointer check for servo constructors

The servo constructors might return a NULL pointer.
The function servo_create() uses servo without checks.

Signed-off-by: Burkhard Ilsen <burkhardilsen@gmail.com>
master
Burkhard Ilsen 2017-04-04 19:20:17 +02:00 committed by Richard Cochran
parent ac92a71161
commit 7e1ccac8f8
1 changed files with 3 additions and 0 deletions

View File

@ -52,6 +52,9 @@ struct servo *servo_create(struct config *cfg, enum servo_type type,
return NULL; return NULL;
} }
if (!servo)
return NULL;
servo_step_threshold = config_get_double(cfg, NULL, "step_threshold"); servo_step_threshold = config_get_double(cfg, NULL, "step_threshold");
if (servo_step_threshold > 0.0) { if (servo_step_threshold > 0.0) {
servo->step_threshold = servo_step_threshold * NSEC_PER_SEC; servo->step_threshold = servo_step_threshold * NSEC_PER_SEC;