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

rubysrc2cpg: Checked statement list size to avoid crash #3253

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

rahul-privado
Copy link
Contributor

@rahul-privado rahul-privado commented Jul 26, 2023

The class << x has no implementation and returns no statement ASTs. This caused a crash in the statement Seq(lastStmtAsReturn(stCtx.getText, stAsts.head)) since stAsts was a empty list.

Put a check for the list size to avoid a crash. Wrote a test for the same.
A proper implementation of class << x will avoid this issue. However, that will be in a separate PR. This one only avoids the crash.

@xavierpinho

@xavierpinho xavierpinho self-requested a review July 26, 2023 10:21
@xavierpinho xavierpinho merged commit 792223b into joernio:master Jul 26, 2023
5 checks passed
@rahul-privado rahul-privado deleted the stmt-size-fix branch July 26, 2023 11:11
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