[Mesa-dev] [PATCH] mesa/marshal: fix glNamedBufferData with NULLdata
Marc Dietrich
marvin24 at gmx.de
Mon Jul 10 20:14:55 UTC 2017
Am Montag, 10. Juli 2017, 16:28:28 CEST schrieb Grigori Goronzy:
> The semantics are similar to glBufferData. Fixes a crash with VMWare
> Player.
>
> Signed-off-by: Grigori Goronzy <greg at chown.ath.cx>
Tested-by: Marc Dietrich <marvin24 at gmx.de>
> ---
> src/mesa/main/marshal.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c
> index 8db4531..b801bdc 100644
> --- a/src/mesa/main/marshal.c
> +++ b/src/mesa/main/marshal.c
> @@ -415,6 +415,7 @@ struct marshal_cmd_NamedBufferData
> GLuint name;
> GLsizei size;
> GLenum usage;
> + bool data_null; /* If set, no data follows for "data" */
> /* Next size bytes are GLubyte data[size] */
> };
>
> @@ -425,7 +426,12 @@ _mesa_unmarshal_NamedBufferData(struct gl_context *ctx,
> const GLuint name = cmd->name;
> const GLsizei size = cmd->size;
> const GLenum usage = cmd->usage;
> - const void *data = (const void *) (cmd + 1);
> + const void *data;
> +
> + if (cmd->data_null)
> + data = NULL;
> + else
> + data = (const void *) (cmd + 1);
>
> CALL_NamedBufferData(ctx->CurrentServerDispatch,
> (name, size, data, usage));
> @@ -436,7 +442,7 @@ _mesa_marshal_NamedBufferData(GLuint buffer, GLsizeiptr
> size, const GLvoid * data, GLenum usage)
> {
> GET_CURRENT_CONTEXT(ctx);
> - size_t cmd_size = sizeof(struct marshal_cmd_NamedBufferData) + size;
> + size_t cmd_size = sizeof(struct marshal_cmd_NamedBufferData) + (data ?
> size : 0);
>
> debug_print_marshal("NamedBufferData");
> if (unlikely(size < 0)) {
> @@ -452,8 +458,11 @@ _mesa_marshal_NamedBufferData(GLuint buffer, GLsizeiptr
> size, cmd->name = buffer;
> cmd->size = size;
> cmd->usage = usage;
> - char *variable_data = (char *) (cmd + 1);
> - memcpy(variable_data, data, size);
> + cmd->data_null = !data;
> + if (data) {
> + char *variable_data = (char *) (cmd + 1);
> + memcpy(variable_data, data, size);
> + }
> _mesa_post_marshal_hook(ctx);
> } else {
> _mesa_glthread_finish(ctx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170710/37b28bd4/attachment.sig>
More information about the mesa-dev
mailing list