diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-04-14 06:39:21 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-04-14 06:39:21 +0200 |
commit | 51b1e2dc27441812d7a3006b5d98834c95618e48 (patch) | |
tree | e7cf3e96a95dacd87a575974cf6ed75fdd693be8 | |
parent | 87888fcde5d02d6e9dfc421bdc7c496f0acf8820 (diff) |
Fix undefined behavior when asking about item to fireproof
-rw-r--r-- | src/q_fireprof.cc | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc index 4a88965a..dbf26c0b 100644 --- a/src/q_fireprof.cc +++ b/src/q_fireprof.cc @@ -169,30 +169,28 @@ static bool_ fireproof_enough_points(object_type *o_ptr, int *stack) static bool_ fireproof() { - int ret, item, stack = 0; - object_type *obj2 = NULL; - bool_ ret2; + int item; item_tester_hook = item_tester_hook_proofable; - ret = get_item(&item, - "Which item shall I fireproof?", - "You have no more items I can fireproof, come back when you have some.", - USE_INVEN); + if (!get_item(&item, + "Which item shall I fireproof?", + "You have no more items I can fireproof, come back when you have some.", + USE_INVEN)) + { + return FALSE; + } /* get the object type from the number */ - obj2 = get_object(item); + object_type *obj2 = get_object(item); /* check we have enough points (if we 'got' an item) */ - if (ret == TRUE) { - ret2 = fireproof_enough_points(obj2, &stack); - } - - /* did either routine fail? */ - if ((ret == FALSE) || (ret2 == FALSE)) + int stack = 0; + if (!fireproof_enough_points(obj2, &stack)) { return FALSE; } - else + + /* Do the actual fireproofing */ { bool_ carry_it; object_type *obj3; |