On Fri, Sep 8, 2023 at 6:07 PM Mark Thomas <ma...@apache.org> wrote:
>
> On 08/09/2023 14:27, r...@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > remm pushed a commit to branch main
> > in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >
> >
> > The following commit(s) were added to refs/heads/main by this push:
> >       new e98bd36df2 Avoid three possible NPEs
> > e98bd36df2 is described below
> >
> > commit e98bd36df28c40fb6bc5a6d7fb7751e895ed7096
> > Author: remm <r...@apache.org>
> > AuthorDate: Fri Sep 8 15:27:07 2023 +0200
> >
> >      Avoid three possible NPEs
> >
> >      Found by coverity.
> > ---
> >   java/org/apache/catalina/mbeans/ContextMBean.java | 20 
> > +++++++++++++++++---
> >   1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/java/org/apache/catalina/mbeans/ContextMBean.java 
> > b/java/org/apache/catalina/mbeans/ContextMBean.java
> > index d36ad25ea6..9afea8a392 100644
> > --- a/java/org/apache/catalina/mbeans/ContextMBean.java
> > +++ b/java/org/apache/catalina/mbeans/ContextMBean.java
> > @@ -77,7 +77,12 @@ public class ContextMBean extends 
> > BaseCatalinaMBean<Context> {
> >        */
> >       public String findErrorPage(int errorCode) throws MBeanException {
> >           Context context = doGetManagedResource();
> > -        return context.findErrorPage(errorCode).toString();
> > +        ErrorPage errorPage = context.findErrorPage(errorCode);
> > +        if (errorPage != null) {
> > +            return context.findErrorPage(errorCode).toString();
>
> Shouldn't that be return errorPage.toString() ?

Yes, I messed up ;)

Rémy

>
> > +        } else {
> > +            return null;
> > +        }
> >       }
> >
> >
> > @@ -91,7 +96,12 @@ public class ContextMBean extends 
> > BaseCatalinaMBean<Context> {
> >        */
> >       public String findErrorPage(Throwable exceptionType) throws 
> > MBeanException {
> >           Context context = doGetManagedResource();
> > -        return context.findErrorPage(exceptionType).toString();
> > +        ErrorPage errorPage = context.findErrorPage(exceptionType);
> > +        if (errorPage != null) {
> > +            return errorPage.toString();
> > +        } else {
> > +            return null;
> > +        }
> >       }
> >
> >
> > @@ -128,7 +138,11 @@ public class ContextMBean extends 
> > BaseCatalinaMBean<Context> {
> >           Context context = doGetManagedResource();
> >
> >           FilterDef filterDef = context.findFilterDef(name);
> > -        return filterDef.toString();
> > +        if (filterDef != null) {
> > +            return filterDef.toString();
> > +        } else {
> > +            return null;
> > +        }
> >       }
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: dev-h...@tomcat.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to