Verify: Is it legal to free dogs from hot cars?

A post spreading on social media claims if you see a dog locked in a hot car, it is legal to break the window to free the animal.