A Buffalo man has pleaded guilty to drug and child-endangerment charges for an incident in which he flung heroin in a hotel room as Town of Tonawanda police showed up with a search warrant on Oct. 30, according to the Erie County District Attorney’s Office.

Indaleccio Rodriguez-Escalara, 22, of 14th Street, jumped from a bed and flung the heroin, covering the bed and his three children, District Attorney Frank A. Sedita III said on Wednesday.

The three children were treated in Women & Children’s Hospital and released.

Police officers recovered more than six grams of heroin in the Economy Inn hotel room on Grand Island Boulevard, according to Sedita’s office.

Rodriguez-Escalara pleaded guilty to fourth-degree criminal possession of a controlled substance and endangering the welfare of a child. He faces up to 5½ years in prison when sentenced by Erie County Judge Thomas P. Franczyk on Jan. 4.