Commit 215e2d7f authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: D3DXQuaternionToAxisAngle should not crash on NULLs in output parameters.

parent 546c55a0
......@@ -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_____________________*/
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment