[spine-c] Fixed floating point exception - division by zero (#1706)

This commit is contained in:
Alexander Akhundzhanov 2020-08-26 17:23:01 +03:00 committed by GitHub
parent 4927c2be63
commit 297fc2f438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -110,6 +110,7 @@
#define SQRT(A) sqrtf(A)
#define ACOS(A) acosf(A)
#define POW(A,B) pow(A, B)
#define ISNAN(A) (int)isnan(A)
#else
#define FMOD(A,B) (float)fmod(A, B)
#define ATAN2(A,B) (float)atan2(A, B)
@ -118,6 +119,7 @@
#define SQRT(A) (float)sqrt(A)
#define ACOS(A) (float)acos(A)
#define POW(A,B) (float)pow(A, B)
#define ISNAN(A) (int)isnan(A)
#endif
#define SIN_DEG(A) SIN((A) * DEG_RAD)

View File

@ -212,18 +212,12 @@ static void _addAfterPosition (float p, float* temp, int i, float* out, int o) {
out[o + 2] = r;
}
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
static int _isNan(float value, float zero) {
float _nan = (float)0.0 / zero;
return 0 == memcmp((void*)&value, (void*)&_nan, sizeof(value));
}
static void _addCurvePosition (float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2,
float* out, int o, int/*bool*/tangents) {
float tt, ttt, u, uu, uuu;
float ut, ut3, uut3, utt3;
float x, y;
if (p == 0 || _isNan(p, 0)) {
if (p == 0 || ISNAN(p)) {
out[o] = x1;
out[o + 1] = y1;
out[o + 2] = ATAN2(cy1 - y1, cx1 - x1);