Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDF parsing to avoid overflow error #722

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Fix SDF parsing to avoid overflow error #722

merged 1 commit into from
Sep 22, 2023

Conversation

dxdc
Copy link
Contributor

@dxdc dxdc commented Sep 22, 2023

The while loop should stop executing its body in two scenarios:

  • When it finds the string "$$$$" at the offset index within the lines array.
  • When the offset index reaches or exceeds the length of the lines array.

The second check was not being performed.

For reference, the last frame in this file did not have the final delimiter. Not sure why, but it shouldn't hang parsing in any event.

$$$$
M0041

Created by GaussView 6.0.16
 16 16  0  0  0  0  0  0  0  0  0    0
   -1.3437   -0.3857   -0.2426 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.4242   -0.2833   -0.2771 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1147   -1.4484   -0.3272 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6553    0.3753   -1.3686 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.2543    0.9300   -2.0784 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.6553    0.3753   -1.3686 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2543    0.9300   -2.0784 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.3437   -0.3857   -0.2426 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.1147   -1.4484   -0.3272 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.4242   -0.2833   -0.2771 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.7801    0.1352    1.1077 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.1441    1.1477    1.2604 H   0  0  0  0  0  0  0  0  0  0  0  0
    1.1586   -0.4709    1.9260 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.7801    0.1352    1.1077 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1441    1.1477    1.2604 H   0  0  0  0  0  0  0  0  0  0  0  0
   -1.1586   -0.4709    1.9260 H   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  3  1  0  0  0  0
  1  4  4  0  0  0  0
  1 14  1  0  0  0  0
  4  5  1  0  0  0  0
  4  6  4  0  0  0  0
  6  7  1  0  0  0  0
  6  8  4  0  0  0  0
  8  9  1  0  0  0  0
  8 10  1  0  0  0  0
  8 11  1  0  0  0  0
 11 12  1  0  0  0  0
 11 13  1  0  0  0  0
 11 14  4  0  0  0  0
 14 15  1  0  0  0  0
 14 16  1  0  0  0  0
M  END

The while loop should stop executing its body in two scenarios:

- When it finds the string "$$$$" at the offset index within the lines array.
- When the offset index reaches or exceeds the length of the lines array.

The second check was not being performed.
Copy link
Contributor

@dkoes dkoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

@dkoes dkoes merged commit 1f0b0f0 into 3dmol:master Sep 22, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants