From c7aa8c89b194fcfd489ee2eef32587d323ac6d2d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 29 Oct 2015 09:22:00 +0100 Subject: [PATCH] coverity scan CID 22551: dereference before null check --- src/spells/shipcurse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/spells/shipcurse.c b/src/spells/shipcurse.c index 29e4ad8f8..4b0dd9b30 100644 --- a/src/spells/shipcurse.c +++ b/src/spells/shipcurse.c @@ -138,9 +138,11 @@ curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration) /* mit C_SHIP_NODRIFT haben wir kein Problem */ curse *c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0); - c->data.v = sh; - if (c && c->duration > 0) { - sh->flags |= SF_FLYING; + if (c) { + c->data.v = sh; + if (c->duration > 0) { + sh->flags |= SF_FLYING; + } } return c; }