From 7e1ccac8f8fbd6e6df5c96aae64ee8dea954b5aa Mon Sep 17 00:00:00 2001 From: Burkhard Ilsen Date: Tue, 4 Apr 2017 19:20:17 +0200 Subject: [PATCH] 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 --- servo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/servo.c b/servo.c index 9aab7f2..8be4b92 100644 --- a/servo.c +++ b/servo.c @@ -52,6 +52,9 @@ struct servo *servo_create(struct config *cfg, enum servo_type type, return NULL; } + if (!servo) + return NULL; + servo_step_threshold = config_get_double(cfg, NULL, "step_threshold"); if (servo_step_threshold > 0.0) { servo->step_threshold = servo_step_threshold * NSEC_PER_SEC;