[Android] Gracefully handle a shared memory creation failure
ashmem_create_region() returns -error_code on failure. ScopedFD treats only -1 as invalid handle meaning that ScopedFD will try to close a file descriptor with a negative value other than -1. ScopedFD crashes when close() fails. This CL adds a check that the result of ashmem_create_region() is non-negative before wrapping it into a ScopedFD. This CL also adds a check that the rounding operation doesn't overflow which was the reason of the failure in the first place. Bug: 1022582 Change-Id: Id2dcec613e87c8eda97bf18cbd70f13b105b1e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913239 Commit-Queue: Alex Ilin <alexilin@chromium.org> Reviewed-by:Robert Sesek <rsesek@chromium.org> Cr-Commit-Position: refs/heads/master@{#714884}
Showing
Please register or sign in to comment