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.8.0~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=187d89d3e7f80f79f50eea6f70f3a0a937aaf67e;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.