Mesa (master): glsl/blob: Do not call memcpy if there is nothing to copy
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 19 10:43:29 UTC 2020
Module: Mesa
Branch: master
Commit: d800bcd9b9664dbb0c8476ee628a3eb888802b87
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d800bcd9b9664dbb0c8476ee628a3eb888802b87
Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date: Tue Jan 28 16:53:02 2020 +0200
glsl/blob: Do not call memcpy if there is nothing to copy
../src/util/blob.c:166:7: runtime error: null pointer passed as argument 2, which is declared to never be null
#0 0x7fe51bc315df in blob_write_bytes ../src/util/blob.c:166
#1 0x7fe51c7a7b9a in iris_disk_cache_store ../src/gallium/drivers/iris/iris_disk_cache.c:115
#2 0x7fe51c7f444d in iris_compile_fs ../src/gallium/drivers/iris/iris_program.c:1693
#3 0x7fe51c7fdcd9 in iris_create_fs_state ../src/gallium/drivers/iris/iris_program.c:2331
#4 0x7fe519e871a3 in st_create_fp_variant ../src/mesa/state_tracker/st_program.c:1275
#5 0x7fe519e89dd0 in st_get_fp_variant ../src/mesa/state_tracker/st_program.c:1435
#6 0x7fe519ed51e1 in st_update_fp ../src/mesa/state_tracker/st_atom_shader.c:163
#7 0x7fe519eb5d73 in st_validate_state ../src/mesa/state_tracker/st_atom.c:261
#8 0x7fe519e4e0bf in prepare_draw ../src/mesa/state_tracker/st_draw.c:132
#9 0x7fe519e4e76e in st_draw_vbo ../src/mesa/state_tracker/st_draw.c:184
#10 0x7fe51aca5245 in vbo_save_playback_vertex_list ../src/mesa/vbo/vbo_save_draw.c:215
#11 0x7fe51a25b1cc in ext_opcode_execute ../src/mesa/main/dlist.c:1126
#12 0x7fe51a2f8d58 in execute_list ../src/mesa/main/dlist.c:11830
#13 0x7fe51a34b2d0 in _mesa_CallList ../src/mesa/main/dlist.c:14267
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3825>
---
src/util/blob.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/blob.c b/src/util/blob.c
index 94d5a9dea74..e4000334e0a 100644
--- a/src/util/blob.c
+++ b/src/util/blob.c
@@ -162,7 +162,7 @@ blob_write_bytes(struct blob *blob, const void *bytes, size_t to_write)
VG(VALGRIND_CHECK_MEM_IS_DEFINED(bytes, to_write));
- if (blob->data)
+ if (blob->data && to_write > 0)
memcpy(blob->data + blob->size, bytes, to_write);
blob->size += to_write;
@@ -286,7 +286,7 @@ blob_copy_bytes(struct blob_reader *blob, void *dest, size_t size)
const void *bytes;
bytes = blob_read_bytes(blob, size);
- if (bytes == NULL)
+ if (bytes == NULL || size == 0)
return;
memcpy(dest, bytes, size);
More information about the mesa-commit
mailing list