[v2] d3dx: D3DXQuaternionToAxisAngle should not crash on NULLs in output parameters.
Paul Gofman
gofmanp at gmail.com
Thu Feb 25 08:34:04 CST 2016
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
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)
--
2.5.0
More information about the wine-patches
mailing list