From d800bcd9b9664dbb0c8476ee628a3eb888802b87 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Tue, 28 Jan 2020 16:53:02 +0200 Subject: [PATCH] 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 Reviewed-by: Lionel Landwerlin Part-of: --- 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); -- 2.30.2