Skip to content

A lot of potential Index Out Of Bounds #19

Open
@jrouaix

Description

@jrouaix

Hello,

We had an ios 18.0 beta 4 sysdiag that made this lib panic! (@ReturnRei will perhaps provide more details)

I quick fixed it in this commit :
shindan-io@fc30ecf

But I find my fix just ugly, i'm far from confident in the existing code.

The code heavy rely on array[index] indexers, which can panic!.
On other way could be to forget about indexers and use the array.get(index) that returns an Option and let us all the semantics to handle the missing case properly.

Same goes with subslicing, slice[x..] could be replaced by get(x..) too.

let array = &vec![1, 2, 3, 4, 5];
let _will_panic = array[42]; // will panic
let _ok = array.get(42); // returns Option::None
let _will_panic = &array[42..]; // will panic
let _ok = array.get(42..); // returns Option::None

Are you aware if this ?
Do you think it's a flaw and that needs some fixing effort ?
Can we help ?

(I can submit a PR with my quick fix, but as said, I think it's a far more general problem and perhaps we should fix it for good)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions