Avoid unsafe static_cast<network::mojom::ReferrerPolicy>(i) casts.
Casting a raw integer (e.g. an integer deserialized from session restore files, from a protobug, or coming from the other side of JNI boundary) to an enum class value may potentially cause the following problems: - Invalid enum values may cause Chromium code to misbehave. - It is not entirely clear if C++ spec allows such casts (i.e. if such casts may lead to undefined behavior). Because of the above, this CL replaces: static_cast<network::mojom::ReferrerPolicy>(raw_integer) casts with calls to a new content::Referrer::ConvertToPolicy static helper method, which tries to ensure that the cast is done in a safe way. Bug: 1006409 Change-Id: I2a660c4caf961ca52503b084a7c0abe93e9d5eb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816134Reviewed-by:Scott Violet <sky@chromium.org> Reviewed-by:
Nate Chapin <japhet@chromium.org> Reviewed-by:
Ken Rockot <rockot@google.com> Reviewed-by:
Bo <boliu@chromium.org> Reviewed-by:
Andrew Grieve <agrieve@chromium.org> Reviewed-by:
Alex Moshchuk <alexmos@chromium.org> Reviewed-by:
Daniel Cheng <dcheng@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Commit-Position: refs/heads/master@{#706044}
Showing
Please register or sign in to comment