mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Ruby: reject ArrayElement[-n] instead of interpreting it as ArrayElement[?]
This commit is contained in:
@@ -32,12 +32,18 @@ module SummaryComponent {
|
||||
/** Gets a summary component that represents an element in an array at an unknown index. */
|
||||
SummaryComponent arrayElementUnknown() { result = SC::content(TUnknownArrayElementContent()) }
|
||||
|
||||
/** Gets a summary component that represents an element in an array at a known index. */
|
||||
/**
|
||||
* Gets a summary component that represents an element in an array at a known index.
|
||||
*
|
||||
* Has no result for negative indices. Wrap-around interpretation of negative indices should be
|
||||
* handled by the caller, if modeling a function that has such behavior.
|
||||
*/
|
||||
bindingset[i]
|
||||
SummaryComponent arrayElementKnown(int i) {
|
||||
result = SC::content(TKnownArrayElementContent(i))
|
||||
or
|
||||
// `i` may be out of range
|
||||
i >= 0 and
|
||||
not exists(TKnownArrayElementContent(i)) and
|
||||
result = arrayElementUnknown()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user