mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
Check whether pitch is actually a sane number
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "wrap_Source.h"
|
||||
|
||||
namespace love
|
||||
@@ -78,6 +80,10 @@ int w_Source_setPitch(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
float p = (float)luaL_checknumber(L, 2);
|
||||
if (p > std::numeric_limits<lua_Number>::max() ||
|
||||
p < std::numeric_limits<lua_Number>::min() ||
|
||||
p != p)
|
||||
return luaL_error(L, "Pitch has to be finite and not NaN.");
|
||||
t->setPitch(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user