From 30a464cad777b364a053f3d07e16840bbf94b66a Mon Sep 17 00:00:00 2001 From: hedgecrw85 Date: Mon, 11 Feb 2019 09:53:10 -0600 Subject: [PATCH] Ensure no NullPointerException is thrown when reading ldd --- src/main/java/com/fazecast/jSerialComm/SerialPort.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fazecast/jSerialComm/SerialPort.java b/src/main/java/com/fazecast/jSerialComm/SerialPort.java index ed3cf05..6b13591 100644 --- a/src/main/java/com/fazecast/jSerialComm/SerialPort.java +++ b/src/main/java/com/fazecast/jSerialComm/SerialPort.java @@ -2,10 +2,10 @@ * SerialPort.java * * Created on: Feb 25, 2012 - * Last Updated on: Oct 29, 2018 + * Last Updated on: Feb 11, 2019 * Author: Will Hedgecock * - * Copyright (C) 2012-2018 Fazecast, Inc. + * Copyright (C) 2012-2019 Fazecast, Inc. * * This file is part of jSerialComm. * @@ -169,11 +169,12 @@ public final class SerialPort libraryPath += "-hf"; else { + String line; ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "ls /lib/ld-linux*"); Process p = pb.start(); p.waitFor(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); - if (br.readLine().contains("armhf")) + if (((line = br.readLine()) != null) && line.contains("armhf")) libraryPath += "-hf"; else { @@ -181,7 +182,7 @@ public final class SerialPort p = pb.start(); p.waitFor(); br = new BufferedReader(new InputStreamReader(p.getInputStream())); - if (br.readLine().contains("armhf")) + if (((line = br.readLine()) != null) && line.contains("armhf")) libraryPath += "-hf"; } }