Fix memory leak when initializing DH parameters in backend

When loading DH parameters used for the generation of ephemeral DH keys
in the backend, the code has never bothered releasing the memory used
for the DH information loaded from a file or from libpq's default.  This
commit makes sure that the information is properly free()'d.

Note that as SSL parameters can be reloaded, this can cause an accumulation
of memory leaked.  As the leak is minor, no backpatch is done.

Reported-by: Dmitry Uspenskiy
Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org
This commit is contained in:
Michael Paquier 2019-12-14 18:17:31 +09:00
parent 7c85be08a2
commit e0e569e1d1
1 changed files with 3 additions and 0 deletions

View File

@ -1015,8 +1015,11 @@ initialize_dh(SSL_CTX *context, bool isServerStart)
(errcode(ERRCODE_CONFIG_FILE_ERROR),
(errmsg("DH: could not set DH parameters: %s",
SSLerrmessage(ERR_get_error())))));
DH_free(dh);
return false;
}
DH_free(dh);
return true;
}