nvc0/ir: fix use after free in texture barrier insertion pass
authorTiziano Bacocco <tizbac2@gmail.com>
Tue, 30 Jul 2013 20:04:49 +0000 (22:04 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sun, 1 Sep 2013 18:51:39 +0000 (20:51 +0200)
Fixes crash with Amnesia: The Dark Descent.

Cc: "9.2 and 9.1" <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/nvc0/codegen/nv50_ir_lowering_nvc0.cpp

index 251e49b..1832e1a 100644 (file)
@@ -443,6 +443,7 @@ NVC0LegalizePostRA::insertTextureBarriers(Function *fn)
          if (i->op == OP_TEXBAR) {
             if (i->subOp >= max) {
                delete_Instruction(prog, i);
+               i = NULL;
             } else {
                max = i->subOp;
                if (prev && prev->op == OP_TEXBAR && prev->subOp >= max) {
@@ -454,7 +455,7 @@ NVC0LegalizePostRA::insertTextureBarriers(Function *fn)
          if (isTextureOp(i->op)) {
             max++;
          }
-         if (!i->isNop())
+         if (i && !i->isNop())
             prev = i;
       }
    }