Rule #1 Never let your dog play with a loaded gun unless the safety is on.
Rule #2 Dogs should never let their owners handle a loaded gun unless they know how to handle one.
Somebody brought the gun into the house, and dropped it. The gun went off and fired a bullet into the ceiling.
It's the gun's fault.