primegen: Fix memory leak for invalid call sequences.
* cipher/primegen.c (prime_generate_internal): Refactor generator code to not leak memory for non-implemented feature. (_gcry_prime_group_generator): Refactor to not leak memory for invalid args. Also make sure that R_G is set as soon as possible.
- GnuPG-bug-id: T1705
- Signed-off-by: Werner Koch <wk@gnupg.org>