diff options
author | Rob Herring <[email protected]> | 2017-05-31 19:07:40 -0500 |
---|---|---|
committer | Rob Herring <[email protected]> | 2017-06-07 20:44:26 -0500 |
commit | 18348a383dae41567fd333db6f848fbc8ff7d99b (patch) | |
tree | cc018cacfd7de3350a127df1ea8f88f7da387cab /src/compiler/glsl/blob.c | |
parent | 4453fbb02447288e21206a676a24ff70b64857b1 (diff) |
glsl: fix bounds check in blob_overwrite_bytes
clang gives a warning in blob_overwrite_bytes because offset type is
size_t which is unsigned:
src/compiler/glsl/blob.c:110:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (offset < 0 || blob->size - offset < to_write)
~~~~~~ ^ ~
Remove the less than 0 check to fix this.
Additionally, if offset is greater than blob->size, the 2nd check would
be false due to unsigned math. Rewrite the check to avoid subtraction.
Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
Diffstat (limited to 'src/compiler/glsl/blob.c')
-rw-r--r-- | src/compiler/glsl/blob.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/glsl/blob.c b/src/compiler/glsl/blob.c index 769ebf1a023..db362520650 100644 --- a/src/compiler/glsl/blob.c +++ b/src/compiler/glsl/blob.c @@ -107,7 +107,7 @@ blob_overwrite_bytes(struct blob *blob, size_t to_write) { /* Detect an attempt to overwrite data out of bounds. */ - if (offset < 0 || blob->size - offset < to_write) + if (blob->size < offset + to_write) return false; memcpy(blob->data + offset, bytes, to_write); |