Merge pull request #68813 from dzil123/v3_fix_fog_shader_buffer_overflow

[3.x] Fix shader compiler asan out of bounds
This commit is contained in:
Rémi Verschelde 2022-11-19 00:43:32 +01:00
commit ab65273087
No known key found for this signature in database
GPG key ID: C3336907360768E1
5 changed files with 34 additions and 0 deletions

View file

@ -1680,6 +1680,9 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_USAMPLER3D: {
// Not implemented in GLES2
} break;
default: {
}
}
p_param_list->push_back(pi);

View file

@ -2460,6 +2460,8 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "CubeMap";
} break;
default: {
}
};
p_param_list->push_back(pi);

View file

@ -114,6 +114,8 @@ static int _get_datatype_size(SL::DataType p_type) {
return 16;
case SL::TYPE_STRUCT:
return 0;
default: {
}
}
ERR_FAIL_V(0);
@ -185,6 +187,8 @@ static int _get_datatype_alignment(SL::DataType p_type) {
return 16;
case SL::TYPE_STRUCT:
return 0;
default: {
}
}
ERR_FAIL_V(0);

View file

@ -928,6 +928,8 @@ String ShaderLanguage::get_datatype_name(DataType p_type) {
return "samplerExternalOES";
case TYPE_STRUCT:
return "struct";
default: {
}
}
return "";
@ -2703,6 +2705,8 @@ Variant ShaderLanguage::constant_value_to_variant(const Vector<ShaderLanguage::C
break;
case ShaderLanguage::TYPE_VOID:
break;
default: {
}
}
return value;
}
@ -2788,8 +2792,18 @@ ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_FLOAT,
TYPE_VOID,
};
static_assert(sizeof(scalar_types) / sizeof(*scalar_types) == TYPE_MAX, "get_scalar_type must be updated if DataType is updated");
return scalar_types[p_type];
}
@ -2819,8 +2833,18 @@ int ShaderLanguage::get_cardinality(DataType p_type) {
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
};
static_assert(sizeof(cardinality_table) / sizeof(*cardinality_table) == TYPE_MAX, "get_cardinality must be updated if DataType is updated");
return cardinality_table[p_type];
}

View file

@ -211,6 +211,7 @@ public:
TYPE_SAMPLERCUBE,
TYPE_SAMPLEREXT,
TYPE_STRUCT,
TYPE_MAX,
};
enum DataPrecision {