From 1087eb53144cb34e20f82595187ce70853fe4cd9 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 3 Jun 2014 10:47:48 +0200 Subject: [PATCH] obj: Fix dereference before NULL check The check for !obj indicates that obj might be NULL, thus move the call to obj_ops(obj) - which dereferences obj - after the check. Signed-off-by: Tobias Klauser Acked-by: Thomas Graf Signed-off-by: Thomas Haller --- lib/object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/object.c b/lib/object.c index c3751a6..405912b 100644 --- a/lib/object.c +++ b/lib/object.c @@ -110,13 +110,14 @@ struct nl_derived_object { struct nl_object *nl_object_clone(struct nl_object *obj) { struct nl_object *new; - struct nl_object_ops *ops = obj_ops(obj); + struct nl_object_ops *ops; int doff = offsetof(struct nl_derived_object, data); int size; if (!obj) return NULL; + ops = obj_ops(obj); new = nl_object_alloc(ops); if (!new) return NULL;