Skip to content

Commit

Permalink
hermes | sandbox | Explicitly use the unsigned int32 for SandboxValue…
Browse files Browse the repository at this point in the history
…Kind to prevent sign bit to be used for the pointer mask.

Summary:
By default this will change the sign bit on the integer and we'll get a warning about overflow.
Explicitly qualify the values as unsigned to prevent that from happening.

Reviewed By: neildhar

Differential Revision: D54602929

fbshipit-source-id: 6e806dbb04403ce2c4346a179ce17062cfa0aae5
  • Loading branch information
nlutsenko authored and facebook-github-bot committed Mar 7, 2024
1 parent c2c711c commit dfdc43f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions API/hermes_sandbox/HermesSandboxRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ struct SandboxPropNameIDListPtrOrError {
};

/// Always set the top bit for pointers so they can be easily checked.
#define SANDBOX_POINTER_MASK (1 << 31)
#define SANDBOX_POINTER_MASK (1u << 31)

enum SandboxValueKind {
enum SandboxValueKind : uint32_t {
SandboxValueKindUndefined = 0,
SandboxValueKindNull = 1,
SandboxValueKindBoolean = 2,
SandboxValueKindError = 3,
SandboxValueKindNumber = 4,
SandboxValueKindSymbol = 5 | SANDBOX_POINTER_MASK,
SandboxValueKindBigInt = 6 | SANDBOX_POINTER_MASK,
SandboxValueKindString = 7 | SANDBOX_POINTER_MASK,
SandboxValueKindObject = 9 | SANDBOX_POINTER_MASK,
SandboxValueKindSymbol = 5u | SANDBOX_POINTER_MASK,
SandboxValueKindBigInt = 6u | SANDBOX_POINTER_MASK,
SandboxValueKindString = 7u | SANDBOX_POINTER_MASK,
SandboxValueKindObject = 9u | SANDBOX_POINTER_MASK,
};

struct SandboxValue {
Expand Down

0 comments on commit dfdc43f

Please sign in to comment.