From cd58024e40147f871d5a871c8ded90808da99474 Mon Sep 17 00:00:00 2001 From: Groove Date: Sun, 29 Jul 2018 23:30:35 +0200 Subject: [PATCH] - Fixed infinite loop in random functions when using negative radius values using an assert #739 --- glm/gtc/random.inl | 8 ++++++++ readme.md | 1 + 2 files changed, 9 insertions(+) diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 0330ff1f..ed8214d1 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -243,6 +243,8 @@ namespace detail template GLM_FUNC_QUALIFIER vec<2, T, defaultp> diskRand(T Radius) { + assert(Radius > static_cast(0)); + vec<2, T, defaultp> Result(T(0)); T LenRadius(T(0)); @@ -261,6 +263,8 @@ namespace detail template GLM_FUNC_QUALIFIER vec<3, T, defaultp> ballRand(T Radius) { + assert(Radius > static_cast(0)); + vec<3, T, defaultp> Result(T(0)); T LenRadius(T(0)); @@ -279,6 +283,8 @@ namespace detail template GLM_FUNC_QUALIFIER vec<2, T, defaultp> circularRand(T Radius) { + assert(Radius > static_cast(0)); + T a = linearRand(T(0), static_cast(6.283185307179586476925286766559)); return vec<2, T, defaultp>(glm::cos(a), glm::sin(a)) * Radius; } @@ -286,6 +292,8 @@ namespace detail template GLM_FUNC_QUALIFIER vec<3, T, defaultp> sphericalRand(T Radius) { + assert(Radius > static_cast(0)); + T theta = linearRand(T(0), T(6.283185307179586476925286766559f)); T phi = std::acos(linearRand(T(-1.0f), T(1.0f))); diff --git a/readme.md b/readme.md index 20e3177a..e647340b 100644 --- a/readme.md +++ b/readme.md @@ -75,6 +75,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed ICC build errors with constexpr #704 - Fixed defaulted operator= and constructors #791 - Fixed invalid conversion from int scalar with vec4 constructor when using SSE instruction +- Fixed infinite loop in random functions when using negative radius values using an assert #739 ### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22 #### Features: