Influence of foam on the stability characteristics of immiscible flow in porous media