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

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2016-02-25 17:34:04 +03:00 committed by Alexandre Julliard
parent 546c55a09d
commit 215e2d7fed
2 changed files with 16 additions and 7 deletions

View File

@ -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_____________________*/

View File

@ -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)