From 4266791a920e19fd3b37992ee6656c34629a0028 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 23 Dec 2015 23:47:45 +0100 Subject: [PATCH] Prevent potential NPE when configuration file is bad --- src/main/java/de/todesbaum/jsite/main/Configuration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/todesbaum/jsite/main/Configuration.java b/src/main/java/de/todesbaum/jsite/main/Configuration.java index ea072d1..b0c7118 100644 --- a/src/main/java/de/todesbaum/jsite/main/Configuration.java +++ b/src/main/java/de/todesbaum/jsite/main/Configuration.java @@ -44,6 +44,7 @@ import de.todesbaum.jsite.application.Node; import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation; import de.todesbaum.util.freenet.fcp2.PriorityClass; +import org.w3c.dom.Document; /** * The configuration. @@ -128,7 +129,10 @@ public class Configuration { StreamCopier.copy(fileInputStream, fileByteOutputStream, configurationFile.length()); fileByteOutputStream.close(); byte[] fileBytes = fileByteOutputStream.toByteArray(); - rootNode = SimpleXML.fromDocument(XML.transformToDocument(fileBytes)); + Document document = XML.transformToDocument(fileBytes); + if (document != null) { + rootNode = SimpleXML.fromDocument(document); + } return; } catch (FileNotFoundException e) { /* ignore. */ -- 2.7.4