[PATCH] d3dx: D3DXQuaternionToAxisAngle should not crash on NULLs in output parameters.
Matteo Bruni
matteo.mystral at gmail.com
Thu Feb 25 08:10:37 CST 2016
2016-02-25 11:36 GMT+01:00 Paul Gofman <gofmanp at gmail.com>:
> Signed-off-by: Paul Gofman <gofmanp at gmail.com>
> ---
> dlls/d3dx9_36/math.c | 12 ++++++++----
> dlls/d3dx9_36/tests/math.c | 5 +++++
> 2 files changed, 13 insertions(+), 4 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..a4e24da 100644
> --- a/dlls/d3dx9_36/tests/math.c
> +++ b/dlls/d3dx9_36/tests/math.c
> @@ -1022,6 +1022,11 @@ static void D3DXQuaternionTest(void)
> D3DXQuaternionToAxisAngle(&nul,&axis,&angle);
> expect_vec3(expectedvec,axis);
> ok(relative_error(angle, expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle);
> +/* test NULLs in output parameters */
> + 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);
> }
Please indent the comment, or maybe (better IMO) just drop it altogether.
Be consistent with whitespace after the comma and no whitespace before the ')'.
Yes, I know, the code right above is broken exactly in the same way...
More information about the wine-devel
mailing list