Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions compiler-rt/lib/scudo/standalone/wrappers_c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,11 @@ INTERFACE WEAK int SCUDO_PREFIX(mallopt)(int param, int value) {
// introduced by interval transition.
SCUDO_ALLOCATOR.releaseToOS(scudo::ReleaseToOS::Force);

if (value == 0) {
// Will set the release values to their minimum values.
value = INT32_MIN;
} else {
// Will set the release values to their maximum values.
// The values allowed on Android are {-1, 0, 1}. "1" means the longest
// interval.
CHECK(value >= -1 && value <= 1);
if (value == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check be value > 0? That more closely matches what it did before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking instead of ">=", maybe we can assert the range of values? given that only three values are valid. (And the description also says 0 and 1 are only allowed numbers)

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be fine with me. We sanitize the values when coming through Android anyway, so verifying a -1, 0, or 1 is probably a better way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. CHECK added.

value = INT32_MAX;
}
}

SCUDO_ALLOCATOR.setOption(scudo::Option::ReleaseInterval,
Expand Down