From fd57e4525aafdc165ec93da042ec67f8d6616cf5 Mon Sep 17 00:00:00 2001 From: habu Date: Thu, 31 Jan 2013 16:11:21 +0000 Subject: [PATCH] Null pointer check added --- src/artifact.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index bc1c2c8da..0e616206e 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -3768,14 +3768,20 @@ bool activate_random_artifact(object_type *o_ptr) } /* Set activation timeout */ - act_ptr = find_activation_info(o_ptr); + act_ptr = find_activation_info(o_ptr); - if (act_ptr->timeout.constant >= 0) { + if (!act_ptr) { + /* Maybe forgot adding information to activation_info table ? */ + msg_format("Activation information is not found: %d.", o_ptr->xtra2); + return FALSE; + } + + if (act_ptr->timeout.constant >= 0) { o_ptr->timeout = act_ptr->timeout.constant; if (act_ptr->timeout.dice > 0) { o_ptr->timeout += randint1(act_ptr->timeout.dice); } - } else { + } else { /* Activations that have special timeout */ switch (o_ptr->xtra2) { case ACT_BR_FIRE: @@ -3792,9 +3798,9 @@ bool activate_random_artifact(object_type *o_ptr) break; default: msg_format("Special timeout is not implemented: %d.", o_ptr->xtra2); - break; + return FALSE; } - } + } return TRUE; } -- 2.11.0