This fix is confusing, because in line 51:
Zstep = (double)veg_con[veg].zone_depth[zone];

What happens in between 51 and 99 is that zone is updated, so that Zstep is no longer equal to (double)veg_con[veg].zone_depth[zone].

I think the correct fix might be to updates Zstep immediately after zone is updated in either line 84 or 88. That would keep the code more readable and the logic intact I think.