Skip to content

Possible unsound public API #22

@charlesxsh

Description

@charlesxsh

The parameter i lacks of sufficient checks and used directly in get_unchecked under safe public function, which might cause memory risks.

pub fn length_of_array(&self, i: usize) -> usize {
let current = unsafe { *self.offsets.get_unchecked(i) };
let next = unsafe { *self.offsets.get_unchecked(i + 1) };
next - current
}

In Rust, we shoud not face memory issues if merely use safe function API.

Suggestion:

  1. add sufficient check
  2. add unsafe to the function declaration to notify the developer

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