radeonsi: fix undefined behavior (memcpy arguments must be non-NULL)
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 30 Apr 2016 04:41:59 +0000 (23:41 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 7 May 2016 21:46:59 +0000 (16:46 -0500)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_state_shaders.c

index 52b9851e01ee58f6a50dd0270843e33b838d15a5..0bfd7e8d111efae4acd5752eda5543956a9e3d57 100644 (file)
@@ -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;
 }