mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
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 <ian.d.romanick@intel.com>
Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:
parent
4453fbb024
commit
18348a383d
1 changed files with 1 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue