free key on error

(cherry picked from commit 607c2d74)
15 jobs for 610-address-memory-leak-on-error-v9_12 in 7 minutes and 46 seconds (queued for 6 seconds)