Skip to content

Commit

Permalink
Check string length of AuxInfo - resolve bug1370.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Sep 3, 2015
1 parent 282550d commit 4eb0299
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -104,7 +104,10 @@ static long[] parseUSmilesNumbers(String aux, IAtomContainer container) {
int label = 1;

if ((index = aux.indexOf("/R:")) >= 0) { // reconnected metal numbers
String[] baseNumbers = aux.substring(index + 8, aux.indexOf('/', index + 8)).split(";");
int endIndex = aux.indexOf('/', index + 8);
if (endIndex<0)
endIndex = aux.length();
String[] baseNumbers = aux.substring(index + 8, endIndex).split(";");
first = new int[baseNumbers.length];
Arrays.fill(first, -1);
for (int i = 0; i < baseNumbers.length; i++) {
Expand Down
Expand Up @@ -164,6 +164,13 @@ public void unlabelledHydrogens() throws Exception {
assertThat(InChINumbersTools.getUSmilesNumbers(container), is(new long[]{2, 1, 3, 4, 5}));
}

@Test
public void bug1370() throws Exception {
IAtomContainer container = new SmilesParser(SilentChemObjectBuilder.getInstance())
.parseSmiles("O=[Bi]Cl");
assertThat(InChINumbersTools.getUSmilesNumbers(container), is(new long[]{3, 1, 2}));
}

static IAtomContainer mock(int nAtoms) {
IAtomContainer container = Mockito.mock(IAtomContainer.class);
when(container.getAtomCount()).thenReturn(nAtoms);
Expand Down

0 comments on commit 4eb0299

Please sign in to comment.