AFLplusplus / AFLplusplus/LibAFL

Redundant Borrowing and Double Mapping in MappedCrossoverInsertMutator::mutate

Open
#3,731 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
481
Avg merge
2d 30m
Merged PRs (30d)
16

Description

### Description

The `MappedCrossoverInsertMutator::mutate` function performs redundant operations when accessing and mapping the corpus input:

1. The testcase is borrowed twice using `get_from_all(id)?.borrow_mut()`.
2. The input is loaded and mapped twice:
- First to compute `other_size`
- Second to retrieve the mapped input for mutation
3. Additional unnecessary `unwrap()` checks increase branching complexity.

This results in:
- Redundant function calls
- Extra borrow operations
- Unnecessary memory allocations
- Reduced readability

### Expected Behavior

The mapped input and its size should be retrieved in a single borrow scope and used directly for mutation without re-loading or re-mapping.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.