From: Ian Romanick Date: Sun, 21 Dec 2014 20:03:09 +0000 (-0800) Subject: mesa: Add missing error checks in _mesa_ProgramBinary X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=201b9c181825551559f6d995007de8ff12d1a54c;p=mesa.git mesa: Add missing error checks in _mesa_ProgramBinary Signed-off-by: Ian Romanick Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke Acked-by: Leight Bade --- diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index e5e9cabc3ed..784fa5c16a7 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1722,8 +1722,31 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat, (void) binaryFormat; (void) binary; - (void) length; - _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramBinary"); + + /* Section 2.3.1 (Errors) of the OpenGL 4.5 spec says: + * + * "If a negative number is provided where an argument of type sizei or + * sizeiptr is specified, an INVALID_VALUE error is generated." + */ + if (length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramBinary(length < 0)"); + return; + } + + /* The ARB_get_program_binary spec says: + * + * " and must be those returned by a previous + * call to GetProgramBinary, and must be the length of the + * program binary as returned by GetProgramBinary or GetProgramiv with + * PROGRAM_BINARY_LENGTH. Loading the program binary will fail, + * setting the LINK_STATUS of to FALSE, if these conditions + * are not met." + * + * Since any value of binaryFormat passed "is not one of those specified as + * allowable for [this] command, an INVALID_ENUM error is generated." + */ + shProg->LinkStatus = GL_FALSE; + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramBinary"); }