General Provisions
Nothing is an offence merely because it's done knowing it might cause harm, if done without criminal intent to harm, and in good faith to prevent or avoid other harm to a person or property - whether the risk was justified is a question of fact.
This protects a genuine "lesser evil" judgment call made in good faith - taking an action known to risk some harm, specifically to prevent a greater harm, isn't a crime, as long as the decision was made honestly and the risk was reasonably justified by the danger being avoided.
A ship's captain who changes course to avoid a collision that would endanger many passengers, even though the new course risks a smaller boat with fewer people aboard, is protected under this section if the decision was made in good faith to minimise overall harm.