From 54ccf5d44d0facf13f6d1af8c5ef9531daafad1c Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 26 Sep 2014 10:52:11 +0200 Subject: [PATCH] - Fixed a possible uninitialized condition. In the function R_RebuildViewInterpolation, the pointer 'iview' was not initialized when the player or its camera were NULL, hence 'iview == NULL' was garbage. Also, the function FindPastViewer does not return NULL, hence the mentioned check is not needed at all. Just return early if the player camera does not exist. --- src/r_utility.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 19d446b5b..585e3dcf3 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -737,24 +737,20 @@ void R_ClearPastViewer (AActor *actor) void R_RebuildViewInterpolation(player_t *player) { - InterpolationViewer *iview; - if (NoInterpolateView) - { - if (player != NULL && player->camera != NULL) - { - iview = FindPastViewer(player->camera); - } + if (player == NULL || player->camera == NULL) + return; - if (iview == NULL) - return; + if (!NoInterpolateView) + return; + NoInterpolateView = false; - NoInterpolateView = false; - iview->oviewx = iview->nviewx; - iview->oviewy = iview->nviewy; - iview->oviewz = iview->nviewz; - iview->oviewpitch = iview->nviewpitch; - iview->oviewangle = iview->nviewangle; - } + InterpolationViewer *iview = FindPastViewer(player->camera); + + iview->oviewx = iview->nviewx; + iview->oviewy = iview->nviewy; + iview->oviewz = iview->nviewz; + iview->oviewpitch = iview->nviewpitch; + iview->oviewangle = iview->nviewangle; } //==========================================================================