ARB prog parser: Prevent NULL ptr deref for KIL instruction
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 30 Jul 2009 16:41:35 +0000 (09:41 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 30 Jul 2009 16:41:35 +0000 (09:41 -0700)
The KIL instruction doesn't have a destination register, so
dereferencing dst in asm_instruction_ctor would cause a segfault.

src/mesa/shader/program_parse.tab.c
src/mesa/shader/program_parse.y

index 1d0719889742af7a7f911a1cd31410d8706db6dd..9b4c4e8277573f7e279a98f45299139db46cd9c6 100644 (file)
@@ -4748,7 +4748,15 @@ asm_instruction_ctor(gl_inst_opcode op,
    if (inst) {
       _mesa_init_instructions(& inst->Base, 1);
       inst->Base.Opcode = op;
-      inst->Base.DstReg = *dst;
+
+      /* In the core ARB extensions only the KIL instruction doesn't have a
+       * destination register.
+       */
+      if (dst == NULL) {
+        init_dst_reg(& inst->Base.DstReg);
+      } else {
+        inst->Base.DstReg = *dst;
+      }
 
       inst->Base.SrcReg[0] = src0->Base;
       inst->SrcReg[0] = *src0;
index 9a5907a4e09bd72026d9a8e6c7f5d8852eeaa191..1a214b38ae8567f66bf519798c543851d3ac2fab 100644 (file)
@@ -1879,7 +1879,15 @@ asm_instruction_ctor(gl_inst_opcode op,
    if (inst) {
       _mesa_init_instructions(& inst->Base, 1);
       inst->Base.Opcode = op;
-      inst->Base.DstReg = *dst;
+
+      /* In the core ARB extensions only the KIL instruction doesn't have a
+       * destination register.
+       */
+      if (dst == NULL) {
+        init_dst_reg(& inst->Base.DstReg);
+      } else {
+        inst->Base.DstReg = *dst;
+      }
 
       inst->Base.SrcReg[0] = src0->Base;
       inst->SrcReg[0] = *src0;