You need to do something like:
```
int charges = cig(p, it, b) );
if( charges != 0 )
    p->hunger += 4;
    p->thirst += 6;
    if (p->pkill < 5) {
        p->pkill += 3;
        p->pkill *= 2;
    }
}
return charges;
```
to prevent the side effects from happening in case cig() fails.