summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2020-11-09 14:25:16 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-11-09 14:31:12 +0200
commit70bdf0ecf2e0f372f1258cd4fe8a72d3c5280611 (patch)
tree3920fa0cb5dbdf275f9fa49ed046f53f7325ecae /thirdparty
parent593e35346ab182c36068c3dcfc741eeb7311a19e (diff)
Update "open-simplex-noise-in-c" to fix undefined signed overflow.
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/README.md2
-rw-r--r--thirdparty/misc/open-simplex-noise.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md
index ac1ce6d5fc..f590acaa0b 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -378,7 +378,7 @@ Collection of single-file libraries used in Godot components.
* License: Apache 2.0
- `open-simplex-noise.{c,h}`
* Upstream: https://github.com/smcameron/open-simplex-noise-in-c
- * Version: git (0d555e7f40527d0870906fe9469a3b1bb4020b7f, 2015) + custom changes
+ * Version: git (0fef0dbedd76f767da7e3c894822729d0f07e54d, 2020) + custom changes
* License: Unlicense
- `pcg.{cpp,h}`
* Upstream: http://www.pcg-random.org
diff --git a/thirdparty/misc/open-simplex-noise.c b/thirdparty/misc/open-simplex-noise.c
index 42f2fbb5be..88fbd3e51d 100644
--- a/thirdparty/misc/open-simplex-noise.c
+++ b/thirdparty/misc/open-simplex-noise.c
@@ -189,14 +189,15 @@ int open_simplex_noise(int64_t seed, struct osn_context *ctx)
permGradIndex3D = ctx->permGradIndex3D;
// -- GODOT end --
+ uint64_t seedU = seed;
for (i = 0; i < 256; i++)
source[i] = (int16_t) i;
- seed = seed * 6364136223846793005LL + 1442695040888963407LL;
- seed = seed * 6364136223846793005LL + 1442695040888963407LL;
- seed = seed * 6364136223846793005LL + 1442695040888963407LL;
+ seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
+ seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
+ seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
for (i = 255; i >= 0; i--) {
- seed = seed * 6364136223846793005LL + 1442695040888963407LL;
- r = (int)((seed + 31) % (i + 1));
+ seedU = seedU * 6364136223846793005ULL + 1442695040888963407ULL;
+ r = (int)((seedU + 31) % (i + 1));
if (r < 0)
r += (i + 1);
perm[i] = source[r];