vrend_decode_clear: fix undefined-behavior for mis-aligned cast

Use memcpy to fix the UBSAN error.

Reviewed-by: Elie Tournier <elie.tournier@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Po-Hsien Wang 6 years ago committed by Dave Airlie
parent 53faae4fc1
commit 967a57bdd1
  1. 3
      src/vrend_decode.c

@ -199,7 +199,8 @@ static int vrend_decode_clear(struct vrend_decode_ctx *ctx, int length)
buffers = get_buf_entry(ctx, VIRGL_OBJ_CLEAR_BUFFERS);
for (i = 0; i < 4; i++)
color.ui[i] = get_buf_entry(ctx, VIRGL_OBJ_CLEAR_COLOR_0 + i);
depth = *(double *)(uint64_t *)get_buf_ptr(ctx, VIRGL_OBJ_CLEAR_DEPTH_0);
double *depth_ptr = (double *)(uint64_t *)get_buf_ptr(ctx, VIRGL_OBJ_CLEAR_DEPTH_0);
memcpy(&depth, depth_ptr, sizeof(double));
stencil = get_buf_entry(ctx, VIRGL_OBJ_CLEAR_STENCIL);
vrend_clear(ctx->grctx, buffers, &color, depth, stencil);

Loading…
Cancel
Save