This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 23e8ca6c85 Avoid potential NPE
23e8ca6c85 is described below

commit 23e8ca6c85f6cb2d520ea55137ff0a80ee07c7ce
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 26 18:21:56 2026 +0100

    Avoid potential NPE
---
 java/org/apache/catalina/realm/JAASMemoryLoginModule.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java 
b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
index 6cde8608e0..a80780152b 100644
--- a/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
+++ b/java/org/apache/catalina/realm/JAASMemoryLoginModule.java
@@ -317,8 +317,10 @@ public class JAASMemoryLoginModule extends MemoryRealm 
implements LoginModule {
     public boolean logout() throws LoginException {
         subject.getPrincipals().remove(principal);
         if (principal instanceof GenericPrincipal) {
-            for (Principal role : roles) {
-                subject.getPrincipals().remove(role);
+            if (roles != null) {
+                for (Principal role : roles) {
+                    subject.getPrincipals().remove(role);
+                }
             }
         }
         committed = false;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to