STAPLES HUGHES, a North Carolina lawyer, was on the witness stand and about to disclose a secret he believed would free an innocent man from prison. But the judge told Mr. Hughes to stop.

“If you testify,” Judge Jack A. Thompson said at a hearing last year on the prisoner’s request for a new trial, “I will be compelled to report you to the state bar. Do you understand that?”

But Mr. Hughes continued. Twenty-two years before, he said, a client, now dead, confessed that he had acted alone in committing a double murder for which another man was also serving life. After his own imprisoned client died, Mr. Hughes recalled last week, “it seemed to me at that point ethically permissible and morally imperative that I spill the beans.”

Judge Thompson, of the Cumberland County Superior Court in Fayetteville, did not see it that way, and some experts in legal ethics agree with him. The obligation to keep a client’s secrets is so important, they say, that it survives death and may not be violated even to cure a grave injustice  for example, the imprisonment for 26 years of another man, in Illinois, who was freed just last month.