A San Diego lawyer is filing a complaint after being stuck inside a waiting room at a local jail for hours during a visit to a client on Tuesday.

Attorney Erubey López told KNSD-TV on Friday that he found himself trapped in the room at the San Diego County Jail for four hours. He said he was later told that the intercom system in the room had been broken for eight months.

"[What] if I was unhealthy, [what] if I had a heart attack?" Erubey Lopez told the station. "What if I had diabetes and had a sugar issue? If they hadn't heard me with that screaming and banging, there was no other way they were going to hear me."

López said he noticed something was wrong after 30 minutes passed without his client being brought to him. But he could not use his cell phone because he surrendered it upon using the facility.

After spending two hours banging on the door and yelling from inside the room, he said, he dealt with the prospect of having to spend the night in jail.

"I have a sweater and a jacket," López said. "I take off my sweater and I try to use it as a pillow."

López was eventually found and released after four hours in the room. San Diego Sheriff's Cmdr. John Ingrassia told U-T San Diego on Friday that López's client was in the process of being booked when the attorney arrived to the jail on Tuesday night, and blamed "a breakdown in communication" for the officers on duty that night not being told.

Ingrassia also said the intercom in the room López was using has been repaired, and that his department has tried to contact the attorney three times to apologize but has not been able to reach him.

Watch KNSD's story on López's brush with incarceration, aired Friday, below.

View more videos at: http://nbcsandiego.com.