Skip to content

fuzz: Fix FUZZ_malloc_rand() to return non-NULL for zero-size allocations#4403

Merged
Cyan4973 merged 1 commit intofacebook:devfrom
dloidolt:fix_FUZZ_malloc_rand
Jun 9, 2025
Merged

fuzz: Fix FUZZ_malloc_rand() to return non-NULL for zero-size allocations#4403
Cyan4973 merged 1 commit intofacebook:devfrom
dloidolt:fix_FUZZ_malloc_rand

Conversation

@dloidolt
Copy link

@dloidolt dloidolt commented Jun 5, 2025

This PR fixes a bug in the FUZZ_malloc_rand helper function introduced in fcaf06d.

The FUZZ_malloc_rand() function was incorrectly always returning NULL for zero-size allocations. The random offset generated by FUZZ_dataProducer_int32Range() was not being added to the pointer variable, causing the function to always return (void *)0.

…ions

The FUZZ_malloc_rand() function was incorrectly always returning NULL for
zero-size allocations. The random offset generated by
FUZZ_dataProducer_int32Range() was not being added to the pointer variable,
causing the function to always return (void *)0.
@dloidolt dloidolt force-pushed the fix_FUZZ_malloc_rand branch from 29a65c6 to 4be08ba Compare June 5, 2025 15:29
@Cyan4973
Copy link
Contributor

Cyan4973 commented Jun 8, 2025

I would really like to understand the perspective of @daniellerozenblit and @terrelln on this test,
because I'm not sure to understand what's the point of returning a junk pointer,
as opposed to just returning a NULL one.

Copy link
Contributor

@terrelln terrelln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@terrelln
Copy link
Contributor

terrelln commented Jun 9, 2025

@Cyan4973 It was to catch UB like this: #3507

There is more context linked in the PR description: #3555

@Cyan4973 Cyan4973 merged commit 88bea95 into facebook:dev Jun 9, 2025
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants