From: Brian Paul Date: Thu, 24 Aug 2006 15:57:12 +0000 (+0000) Subject: Check if mesa_vp->Base.Parameters is null before dereferencing (bug report X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=116411d5f00dd4af6bb2da3a98d57ca6fa2c1d82;p=mesa.git Check if mesa_vp->Base.Parameters is null before dereferencing (bug report from Chris Rankin). Also, fix some bad casts. --- diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index eaed68e7c8e..203bce143b4 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -101,7 +101,7 @@ static GLboolean r200VertexProgUpdateParams(GLcontext *ctx, struct r200_vertex_p r200ContextPtr rmesa = R200_CONTEXT( ctx ); GLfloat *fcmd = (GLfloat *)&rmesa->hw.vpp[0].cmd[VPP_CMD_0 + 1]; int pi; - struct gl_vertex_program *mesa_vp = (void *)vp; + struct gl_vertex_program *mesa_vp = &vp->mesa_program; struct gl_program_parameter_list *paramList; drm_radeon_cmd_header_t tmp; @@ -391,7 +391,7 @@ static unsigned long op_operands(enum prog_opcode opcode) static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) { - struct gl_vertex_program *mesa_vp = (void *)vp; + struct gl_vertex_program *mesa_vp = &vp->mesa_program; struct prog_instruction *vpi; int i; VERTEX_SHADER_INSTRUCTION *o_inst; @@ -544,7 +544,10 @@ static GLboolean r200_translate_vertex_program(struct r200_vertex_program *vp) vp->pos_end = 0; mesa_vp->Base.NumNativeInstructions = 0; - mesa_vp->Base.NumNativeParameters = mesa_vp->Base.Parameters->NumParameters; + if (mesa_vp->Base.Parameters) + mesa_vp->Base.NumNativeParameters = mesa_vp->Base.Parameters->NumParameters; + else + mesa_vp->Base.NumNativeParameters = 0; for(i=0; i < VERT_ATTRIB_MAX; i++) vp->inputs[i] = -1;