Paul Gofman : d3dx9: D3DXQuaternionToAxisAngle should not crash on NULLs in output parameters.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 25 10:56:04 CST 2016
Module: wine
Branch: master
Commit: 215e2d7fed58ccd7c5e55ad536fb311608b51d26
URL: http://source.winehq.org/git/wine.git/?a=commit;h=215e2d7fed58ccd7c5e55ad536fb311608b51d26
Author: Paul Gofman <gofmanp at gmail.com>
Date: Thu Feb 25 17:34:04 2016 +0300
d3dx9: D3DXQuaternionToAxisAngle should not crash on NULLs in output parameters.
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/math.c | 12 ++++++++----
dlls/d3dx9_36/tests/math.c | 11 ++++++++---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index 5e8d51a..123bd2f 100644
--- a/dlls/d3dx9_36/math.c
+++ b/dlls/d3dx9_36/math.c
@@ -1652,10 +1652,14 @@ void WINAPI D3DXQuaternionToAxisAngle(const D3DXQUATERNION *pq, D3DXVECTOR3 *pax
{
TRACE("pq %p, paxis %p, pangle %p\n", pq, paxis, pangle);
- paxis->x = pq->x;
- paxis->y = pq->y;
- paxis->z = pq->z;
- *pangle = 2.0f * acosf(pq->w);
+ if (paxis)
+ {
+ paxis->x = pq->x;
+ paxis->y = pq->y;
+ paxis->z = pq->z;
+ }
+ if (pangle)
+ *pangle = 2.0f * acosf(pq->w);
}
/*_________________D3DXVec2_____________________*/
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index ac4475d..cbe94b5 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -1019,9 +1019,14 @@ static void D3DXQuaternionTest(void)
/* Test the null quaternion */
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
expected = 3.141593f;
- D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
- expect_vec3(expectedvec,axis);
- ok(relative_error(angle, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
+ D3DXQuaternionToAxisAngle(&nul, &axis, &angle);
+ expect_vec3(expectedvec, axis);
+ ok(relative_error(angle, expected) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
+
+ D3DXQuaternionToAxisAngle(&nul, &axis, NULL);
+ D3DXQuaternionToAxisAngle(&nul, NULL, &angle);
+ expect_vec3(expectedvec, axis);
+ ok(relative_error(angle, expected) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
}
static void D3DXVector2Test(void)
More information about the wine-cvs
mailing list