Could the man accused of stalking Sandra Bullock avoid jail due to an illegal search of his home by LAPD detectives?

That may be the case after a California state appeals court found, in a unanimous ruling, that detectives violated accused stalker Joshua Corbett’s “right to remain silent and thus did not obtain valid consent to enter his Montrose home, where detectives found a cache of illegal automatic weapons,” reports the Los Angeles Times.

Due to the court’s decision, all evidence resulting from the search is not admissible in court.

RELATED: Judge Rules That Guns Belonging To Alleged Sandra Bullock Stalker Cannot Be Used In Court

The court’s decision upholds the earlier finding of an L.A. County Superior Court judge, which throws a monkey-wrench into the case presented by the Los Angeles Police Department and the Los Angeles County district attorney’s office, notes the Times.

In fact, the ruling could result in 24 of the 26 felony charges against Corbett being tossed out of court, “gutting most of the case,” reports the Times.

“There is no dispute that Corbett’s 5th Amendment rights were violated here,” states the ruling, issued Tuesday. “The police ignored his repeated and unambiguous invocations of his right to remain silent and continued to interrogate him.”

The appellate court also noted what LAPD Det. Christina Carlozzi wrote to the case’s prosecutor after reviewing a transcript of Corbett’s interrogation: “Doesn’t look good. I honestly hope this can be settled without a trial.”

Shiara Davila-Morales, spokesperson for the DA’s office, said “prosecutors are reviewing the opinion and weighing options on how to proceed,” while a spokesperson for the LAPD declined comment.

RELATED: Sandra Bullock’s 911 Tape: Actress Terrified, Crying in the Closet as Alleged Stalker Invades Home

Corbett was arrested inside Bullock’s mansion in the Hollywood Hills on the morning of June 8, 2014, and was subsequently charged with stalking and burglary, in addition to weapons violations following the search of his home.

According to prosecutors, Bullock — who was alone in the house at the time — was awakened by knocking sounds coming from the third floor of her home. When she peeked out her bedroom door, she saw a man dressed in black walking down the corridor. She hid in her bedroom closet and dialled 911.

Corbett currently remains behind bars on bail of more than $2.1 million.