From 44b37afa94f2aa6dc575835ac508ed214f6b983a Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 31 Jul 2026 17:03:13 +0000
Subject: [PATCH] Fix CodeQL warning-severity alerts: process stream ownership and two leaks (#799)

---
 opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
index f2f12a2..5d69679 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -328,6 +328,15 @@
       }
     }
 
+    if (backend == null)
+    {
+      // Unreachable as long as the checks above hold: a null backend ID implies at least one
+      // include branch, and every include branch either resolves to a backend or is rejected.
+      // The guard mirrors the one in runTask() and keeps the dereference below safe.
+      LocalizableMessage message = ERR_LDIFIMPORT_NO_BACKENDS_FOR_ID.get();
+      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
+    }
+
     // Make sure the selected backend will handle all the include branches
     defaultIncludeBranches = new ArrayList<>(backend.getBaseDNs());
 

--
Gitblit v1.10.0