What happens legally if you sacrifice someone else to save yourself in a shooting, for example?

Okay, so say that you are in a mall, and someone starts shooting. You run, but see the shooter approach you, and fire at you. You grab someone random, who hasn't been shot yet, and forcefully push them in front of you so that the bullet hits them instead of you, saving yourself in the process. This person who you're using as a human shield either gets seriously wounded or ends up dead.

Now, I am curious -- would you be held legally liable for their injuries and/or death? Could you go to prison for doing this? Is it illegal, or could it be excused by stating that your own life was at risk as well?