mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 15:20:10 +01:00
mesa: Use get_local_param_pointer in glProgramLocalParameters4fvEXT().
Using the get_local_param_pointer helper ensures that the LocalParams
arrays have actually been allocated before attempting to use them.
glProgramLocalParameters4fvEXT needs to do a bit of extra checking,
but it can be simplified since the helper has already validated the
target.
Fixes crashes in programs that use Cg (for example, Awesomenauts,
Rocketbirds: Hardboiled Chicken, and Tiny and Big: Grandpa's Leftovers)
since commit e5885c119d
(mesa: Dynamically allocate the storage for program local parameters.)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73136
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Laurent Carlier <lordheavym@gmail.com>
This commit is contained in:
parent
2d368b982a
commit
05fbb021a6
1 changed files with 13 additions and 21 deletions
|
|
@ -527,28 +527,20 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
|||
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)");
|
||||
}
|
||||
|
||||
if (target == GL_FRAGMENT_PROGRAM_ARB
|
||||
&& ctx->Extensions.ARB_fragment_program) {
|
||||
if ((index + count) > ctx->Const.FragmentProgram.MaxLocalParams) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)");
|
||||
return;
|
||||
}
|
||||
dest = ctx->FragmentProgram.Current->Base.LocalParams[index];
|
||||
}
|
||||
else if (target == GL_VERTEX_PROGRAM_ARB
|
||||
&& ctx->Extensions.ARB_vertex_program) {
|
||||
if ((index + count) > ctx->Const.VertexProgram.MaxLocalParams) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)");
|
||||
return;
|
||||
}
|
||||
dest = ctx->VertexProgram.Current->Base.LocalParams[index];
|
||||
}
|
||||
else {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameters4fvEXT(target)");
|
||||
return;
|
||||
}
|
||||
if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
|
||||
target, index, &dest)) {
|
||||
GLuint maxParams = target == GL_FRAGMENT_PROGRAM_ARB ?
|
||||
ctx->Const.FragmentProgram.MaxLocalParams :
|
||||
ctx->Const.VertexProgram.MaxLocalParams;
|
||||
|
||||
memcpy(dest, params, count * 4 * sizeof(GLfloat));
|
||||
if ((index + count) > maxParams) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glProgramLocalParameters4fvEXT(index + count)");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dest, params, count * 4 * sizeof(GLfloat));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue