Skip to content

Commit 5471fae

Browse files
johnmayegonw
authored andcommitted
Daniel Lowe notes passing null here through to the JNI-INCHI can crash the JVM.
1 parent dfbc328 commit 5471fae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

storage/inchi/src/main/java/org/openscience/cdk/inchi/InChIToStructure.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public class InChIToStructure {
112112
* @throws CDKException
113113
*/
114114
protected InChIToStructure(String inchi, IChemObjectBuilder builder) throws CDKException {
115+
if (inchi == null)
116+
throw new NullPointerException();
115117
try {
116118
input = new JniInchiInputInchi(inchi, "");
117119
} catch (JniInchiException jie) {
@@ -127,6 +129,8 @@ protected InChIToStructure(String inchi, IChemObjectBuilder builder) throws CDKE
127129
* @throws CDKException
128130
*/
129131
protected InChIToStructure(String inchi, IChemObjectBuilder builder, String options) throws CDKException {
132+
if (inchi == null)
133+
throw new NullPointerException();
130134
try {
131135
input = new JniInchiInputInchi(inchi, options);
132136
} catch (JniInchiException jie) {
@@ -142,6 +146,8 @@ protected InChIToStructure(String inchi, IChemObjectBuilder builder, String opti
142146
* @throws CDKException
143147
*/
144148
protected InChIToStructure(String inchi, IChemObjectBuilder builder, List<String> options) throws CDKException {
149+
if (inchi == null)
150+
throw new NullPointerException();
145151
try {
146152
input = new JniInchiInputInchi(inchi, options);
147153
} catch (JniInchiException jie) {

0 commit comments

Comments
 (0)