From: Alexandre Montplaisir Date: Thu, 19 May 2016 18:49:06 +0000 (-0400) Subject: Fix: Avoid potential null dereference with log4j loggers X-Git-Tag: v2.9.0-rc1~100 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2b218c9aeb9face9c713c51e7169539deb1b263d;p=lttng-ust.git Fix: Avoid potential null dereference with log4j loggers Coverity warns that the return of LogManager.getCurrentLoggers() can contain null elements. Add an explicit null check to skip those. Signed-off-by: Alexandre Montplaisir Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jAgent.java b/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jAgent.java index 7dcff9ec..6cb74f91 100644 --- a/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jAgent.java +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-log4j/org/lttng/ust/agent/log4j/LttngLog4jAgent.java @@ -55,6 +55,10 @@ class LttngLog4jAgent extends AbstractLttngAgent { @SuppressWarnings("unchecked") List loggers = Collections.list(LogManager.getCurrentLoggers()); for (Logger logger : loggers) { + if (logger == null) { + continue; + } + /* * Check if that logger has at least one LTTng log4j appender * attached.