From 2701b167448253b601e1f33c503ee1d79dcd643b Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 27 Jul 2016 18:44:36 +0800 Subject: [PATCH] Fix potential NPE (e.g. for XML pages that respond with 404 NOT FOUND) @see https://www.filebot.net/forums/viewtopic.php?f=10&t=3989&p=22375#p22375 --- source/net/filebot/util/XPathUtilities.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/util/XPathUtilities.java b/source/net/filebot/util/XPathUtilities.java index ea873f9d..f9356a17 100644 --- a/source/net/filebot/util/XPathUtilities.java +++ b/source/net/filebot/util/XPathUtilities.java @@ -67,11 +67,12 @@ public final class XPathUtilities { } public static String getAttribute(String attribute, Node node) { - Node attributeNode = node.getAttributes().getNamedItem(attribute); - - if (attributeNode != null) - return attributeNode.getNodeValue().trim(); - + if (node != null) { + Node attr = node.getAttributes().getNamedItem(attribute); + if (attr != null) { + return attr.getNodeValue().trim(); + } + } return null; }