No State law was broken but Federal Law was and by ordering the return of a Federally illegal substance the Judge would be breaking Federal law. The Supreme Court will be deciding on Federal rights of arrest in States which have legalised medical cannabis use in October. By which time your half ounce will have been 'officially destroyed', possibly some time after work in a bar near the police station.

Life's a bitch innit.

peace