CleverRaven/Cataclysm-DDA — pull request #9688 by BevapDin (2014-10-25 23:49:42+00:00)
Title: Fix this being null

`this` must not be NULL. The Standard says that calling a member function on a NULL pointer is undefined behavior and nobody likes nasal daemons, so let's fix it.

This fixes #9575

#9078 says it happens in the vehicle interaction window when a part with a tank is selected, but "When the part in question is already greyed out, there is no crash."

I believe the fault is in `game::refill_vehicle_part`, the function is called to test whether the character has some fuel of the required type. The local variable `p_itm` starts with the value NULL, and is set when an item of the required fuel type has been found. Otherwise only `it` is set to non-null (in all cases), but `p_itm` stays NULL. The functions than checks `p_itm->is_null() || it->is_null()`, which crashes because `p_itm` is NULL.

`game::refill_vehicle_part` is called from `veh_interact::cant_do`, but only when the vehicle part is *not* completely broken (hp > 0), this matches the quote above - a tank with 0 hp shows up gray.

I added the required null-check in `game::refill_vehicle_part` (plus some comments), and removed the `this == null` check from `item::is_null`.