Under Terry v. Ohio, an officer is allowed to briefly detain and frisk an individual if that officer has reasonable suspicion that criminal activity is afoot and the officer has reasonable suspicion that individual is armed with a weapon.
Furthermore, if an officer conducts a valid Terry frisk and feels what appears to be contraband, then that contraband will likely fall under the warrant exception as well.
U.S. Supreme Court
We merely hold today that where a police officer observes unusual conduct which leads him reasonably to conclude in light of his experience that criminal activity may be afoot and that the persons with whom he is dealing may be armed and presently dangerous, where in the course of investigating this behavior he identifies himself as a policeman and makes reasonable inquiries, and where nothing in the initial stages of the encounter serves to dispel his reasonable fear for his own or others' safety, he is entitled for the protection of himself and others in the area to conduct a carefully limited search of the outer clothing of such persons in an attempt to discover weapons which might be used to assault him. Terry v. Ohio, 392 U.S. 1, 30 (1968).
The same can be said of tactile discoveries of contraband. If a police officer lawfully pats down a suspect's outer clothing and feels an object whose contour or mass makes its identity immediately apparent, there has been no invasion of the suspect's privacy beyond that already authorized by the officer's search for weapons; if the object is contraband, its warrantless seizure would be justified by the same practical considerations that inhere in the plain-view context. Minnesota v. Dickerson, 508 U.S. 366, 375–76 (1993).