Where the weapon was pointed would be the most paramount issue, and that is easy to pay attention to when the weapon has not malfunctioned.
But when it HAS malfunctioned, now what. The right thing would certainly include alerting everybody in the vicinity so that they would not be downrange of the weapon being worked on. And then constantly keeping aware of where the weapon is pointed, until the jam has been cleared. If it had to be fired or firing attempted or risked to be freed of the jam, at least the work should be done with the weapon pointed in a safe direction in a safe place.
When I was a kid in elementary school in the redneck state of Kentucky, there were lessons on how to handle rifles and what not to do with them, like shoot them at water. But nobody ever covered the situation of what you did if the gun malfunctioned.
The other situation which still makes me uncomfortable is, what to do if you cock a double action revolver and then decide that you do not wish to fire it.
As far as I know there is no alternative to holding the hammer back, pulling the trigger, and then easing the hammer down. I hate that.