OxA: Division by zero

It’s hard a little to produce this bug, but i noticed it while i was loooking at source code:

https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/disease.cpp

[code]
void manage_fungal_infection(player& p, disease& dis)
{
int bonus = p.health + (p.has_trait(“POISRESIST”) ? 100 : 0);
p.moves -= 10;
p.mod_str_bonus(-1);
p.mod_dex_bonus(-1);
if (!dis.permanent) {
if (dis.duration > 3001) { // First hour symptoms
if (one_in(160 + bonus)) {
handle_cough§;
}
if (one_in(100 + bonus)) {
g->add_msg_if_player(&p,(“You feel nauseous.”));
}
if (one_in(100 + bonus)) {
g->add_msg_if_player(&p,
(“You smell and taste mushrooms.”));
}
} else if (dis.duration > 1) { // Five hours of worse symptoms
if (one_in(600 + bonus * 3)) {
g->add_msg_if_player(&p, _(“You spasm suddenly!”));
p.moves -= 100;
p.hurt(bp_torso, -1, 5);
}
if (will_vomit(p, 800 + bonus * 4) || one_in(2000 + bonus * 10)) {
g->add_msg_player_or_npc( &p, _(“You vomit a thick, gray goop.”),
_(" vomits a thick, grey goop.") );

            int awfulness = rng(0,70);
            p.moves = -200;
            p.hunger += awfulness;
            p.thirst += awfulness;
            p.hurt(bp_torso, -1, awfulness / p.str_cur); // can't be healthy
        }
    } else {
        p.add_disease("fungus", 1, true, 1, 1, 0, -1);
    }[/code]
                int awfulness = rng(0,70);
                p.moves = -200;
                p.hunger += awfulness;
                p.thirst += awfulness;
                p.hurt(bp_torso, -1, awfulness / p.str_cur); // can't be healthy

There’s no:
if (p.str_cur == 0) { do something }
and str_cur CAN be 0, so, it will raise runtime error division by zero.

Proof

Thanks for reporting this, I’ve added a github issue and it should hopefully be fixed soon!

Soyweiser fixed it. Thanks.

Thanks a lot for this extended bug report btw. Good find!