Fix memory leak in DH_get_nid()
Fix memory leak in DH_get_nid()

If q is non-NULL but p is indeed a safe prime, a modified copy
of p could be leaked.

Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4525)

openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl