free key on error

(cherry picked from commit 607c2d74)
15 jobs for 610-address-memory-leak-on-error-v9_11 in 14 minutes and 8 seconds (queued for 5 seconds)