gallium/radeon: don't crash when getting out-of-bounds TEMP references
authorMarek Olšák <marek.olsak@amd.com>
Thu, 19 Mar 2015 11:14:08 +0000 (12:14 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 23 Apr 2015 14:14:39 +0000 (16:14 +0200)
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c

index 18afbcb0a2e9f300010f72676764208b33a2a711..20e506b7c5e433058c34cc69a3a637e76a70a2d8 100644 (file)
@@ -191,6 +191,8 @@ emit_fetch(
                break;
 
        case TGSI_FILE_TEMPORARY:
+               if (reg->Register.Index >= ctx->temps_count)
+                       return LLVMGetUndef(tgsi2llvmtype(bld_base, type));
                if (uses_temp_indirect_addressing(bld_base)) {
                        ptr = lp_get_temp_ptr_soa(bld, reg->Register.Index, swizzle);
                        break;
@@ -395,6 +397,8 @@ emit_store(
                                        break;
 
                                case TGSI_FILE_TEMPORARY:
+                                       if (range.First + i >= ctx->temps_count)
+                                               continue;
                                        if (uses_temp_indirect_addressing(bld_base))
                                                temp_ptr = lp_get_temp_ptr_soa(bld, i + range.First, chan_index);
                                        else
@@ -416,6 +420,8 @@ emit_store(
                                break;
 
                        case TGSI_FILE_TEMPORARY:
+                               if (reg->Register.Index >= ctx->temps_count)
+                                       continue;
                                if (uses_temp_indirect_addressing(bld_base)) {
                                        temp_ptr = NULL;
                                        break;