Fix Memory leak in app_passwd

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Mar 10 17:42:48 2026
(Merged from https://github.com/openssl/openssl/pull/30325)
This commit is contained in:
huanghuihui0904 2026-03-09 22:57:00 +08:00 committed by Neil Horman
parent 0d5a73eb38
commit adc8e4abd9

View file

@ -186,8 +186,11 @@ int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2)
}
if (arg2 != NULL) {
*pass2 = app_get_pass(arg2, same ? 2 : 0);
if (*pass2 == NULL)
if (*pass2 == NULL) {
clear_free(*pass1);
*pass1 = NULL;
return 0;
}
} else if (pass2 != NULL) {
*pass2 = NULL;
}