Detectives believe the attack was foiled by a malfunctioning gun