Carbine Williams (1952) was a Drama - Crime Film directed by Richard Thorpe and produced by Armand Deutsch.
Stewart plays a ne'er-do-well drifter in this Western who, through a misunderstanding, finds himself in jail for killing a taxman. Once in prison, he is framed for starting a riot by his fellow inmates. As if the abuse of his fellow inmates wasn't enough, he must protect himself from the creative tortures of the evil warden. Only his indomitable will and mechanical expertise allow him to survive, and he triumphs by inventing the carbine, a new kind of rifle.
(Source: available at Amazon AMC Classic Movie Companion)..