Ensure no NullPointerException is thrown when reading ldd
This commit is contained in:
parent
62fc0f0184
commit
30a464cad7
|
@ -2,10 +2,10 @@
|
||||||
* SerialPort.java
|
* SerialPort.java
|
||||||
*
|
*
|
||||||
* Created on: Feb 25, 2012
|
* Created on: Feb 25, 2012
|
||||||
* Last Updated on: Oct 29, 2018
|
* Last Updated on: Feb 11, 2019
|
||||||
* Author: Will Hedgecock
|
* Author: Will Hedgecock
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2018 Fazecast, Inc.
|
* Copyright (C) 2012-2019 Fazecast, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of jSerialComm.
|
* This file is part of jSerialComm.
|
||||||
*
|
*
|
||||||
|
@ -169,11 +169,12 @@ public final class SerialPort
|
||||||
libraryPath += "-hf";
|
libraryPath += "-hf";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
String line;
|
||||||
ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "ls /lib/ld-linux*");
|
ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "ls /lib/ld-linux*");
|
||||||
Process p = pb.start();
|
Process p = pb.start();
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
if (br.readLine().contains("armhf"))
|
if (((line = br.readLine()) != null) && line.contains("armhf"))
|
||||||
libraryPath += "-hf";
|
libraryPath += "-hf";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -181,7 +182,7 @@ public final class SerialPort
|
||||||
p = pb.start();
|
p = pb.start();
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
if (br.readLine().contains("armhf"))
|
if (((line = br.readLine()) != null) && line.contains("armhf"))
|
||||||
libraryPath += "-hf";
|
libraryPath += "-hf";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue