Commit adc8e4abd9 for openssl.org
commit adc8e4abd962b448354756fef24be499278875ae
Author: huanghuihui0904 <625173@qq.com>
Date: Mon Mar 9 22:57:00 2026 +0800
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)
diff --git a/apps/lib/apps.c b/apps/lib/apps.c
index 9d81264d44..53dbcf2c2d 100644
--- a/apps/lib/apps.c
+++ b/apps/lib/apps.c
@@ -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;
}