From b9e6e8e7d4ed9f9330aabc73e0644fe50460cf9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Fri, 29 Apr 2016 23:41:59 -0500 Subject: [PATCH] radeonsi: fix undefined behavior (memcpy arguments must be non-NULL) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Michel Dänzer Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_state_shaders.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 52b9851e01e..0bfd7e8d111 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -63,7 +63,9 @@ static void *si_get_tgsi_binary(struct si_shader_selector *sel) /** Copy "data" to "ptr" and return the next dword following copied data. */ static uint32_t *write_data(uint32_t *ptr, const void *data, unsigned size) { - memcpy(ptr, data, size); + /* data may be NULL if size == 0 */ + if (size) + memcpy(ptr, data, size); ptr += DIV_ROUND_UP(size, 4); return ptr; } -- 2.30.2