The gun was not the problem anymore than the drugs he was arrested for was the problem. If the "shootout" had occurred during the arrest in the dorm room, you might have a point. But even then questions would be raised as to whether a 19-year-old druggie should have been allowed to legally have a handgun. 
-
The problem was apparently the officer's failure to properly pat down the student for a weapon when he arrested him. The student got a gun from somewhere. If it wasn't the officer's gun (and the story indicates it wasn't), then either the student had it on him all the time or found it laying around somewhere.
-
Failure to conduct a thorough and proper pat down for weapons has lead to numerous officers being injured or killed by guns, knives, and blades for decades. It's nothing new. But "complacency" and the idea that "the kid is cooperating" so "nothing bad will ever happen" has caused too many cops to un-handcuff criminals who just happen to have a weapon on them.