summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-06-10 11:29:28 +0300
committerYuri Rubinsky <chaosus89@gmail.com>2022-06-10 11:35:56 +0300
commitc9ae83b5ab01e3f84bfa27226e9407b98883961c (patch)
tree5b9cf223c4d2bd499d3309bc225309dcbb5bb7e7 /servers
parent8aa69c4e063fa6b34a898416a99081ea2cec75f9 (diff)
Prevent defining float constant without number after exponent in shaders
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/shader_language.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index fe3d1e03b6..f9469fcae0 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -613,12 +613,16 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
String str;
int i = 0;
+ bool digit_after_exp = false;
while (true) {
const char32_t symbol = String::char_lowercase(GETCHAR(i));
bool error = false;
if (is_digit(symbol)) {
+ if (exponent_found) {
+ digit_after_exp = true;
+ }
if (end_suffix_found) {
error = true;
}
@@ -683,7 +687,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant");
}
} else if (period_found || exponent_found || float_suffix_found) { // Float
- if (exponent_found && (!is_digit(last_char) && last_char != 'f')) { // checks for eg: "2E", "2E-", "2E+"
+ if (exponent_found && (!digit_after_exp || (!is_digit(last_char) && last_char != 'f'))) { // Checks for eg: "2E", "2E-", "2E+" and 0ef, 0e+f, 0.0ef, 0.0e-f (exponent without digit after it).
return _make_token(TK_ERROR, "Invalid (float) numeric constant");
}
if (period_found) {