From 5747406776a530798491df7bdcb7c1bdb69dc2b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Aug 2011 06:14:28 +0000 Subject: [PATCH] - fixed some more potential NULL pointer accesses. SVN r3286 (trunk) --- src/g_shared/a_action.cpp | 39 ++++++++++++++++++++------------------ src/g_shared/a_pickups.cpp | 4 ++-- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 1a7c83b893..c283b57206 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -266,9 +266,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) self->x + (((pr_freeze()-128)*self->radius)>>7), self->y + (((pr_freeze()-128)*self->radius)>>7), self->z + (pr_freeze()*self->height/255), ALLOW_REPLACE); - mo->SetState (mo->SpawnState + (pr_freeze()%3)); if (mo) { + mo->SetState (mo->SpawnState + (pr_freeze()%3)); mo->velz = FixedDiv(mo->z - self->z, self->height)<<2; mo->velx = pr_freeze.Random2 () << (FRACBITS-7); mo->vely = pr_freeze.Random2 () << (FRACBITS-7); @@ -281,24 +281,27 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) { // attach the player's view to a chunk of ice AActor *head = Spawn("IceChunkHead", self->x, self->y, self->z + self->player->mo->ViewHeight, ALLOW_REPLACE); - head->velz = FixedDiv(head->z - self->z, self->height)<<2; - head->velx = pr_freeze.Random2 () << (FRACBITS-7); - head->vely = pr_freeze.Random2 () << (FRACBITS-7); - head->health = self->health; - head->angle = self->angle; - if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn))) + if (head != NULL) { - head->player = self->player; - head->player->mo = static_cast(head); - self->player = NULL; - head->ObtainInventory (self); - } - head->pitch = 0; - head->RenderStyle = self->RenderStyle; - head->alpha = self->alpha; - if (head->player->camera == self) - { - head->player->camera = head; + head->velz = FixedDiv(head->z - self->z, self->height)<<2; + head->velx = pr_freeze.Random2 () << (FRACBITS-7); + head->vely = pr_freeze.Random2 () << (FRACBITS-7); + head->health = self->health; + head->angle = self->angle; + if (head->IsKindOf(RUNTIME_CLASS(APlayerPawn))) + { + head->player = self->player; + head->player->mo = static_cast(head); + self->player = NULL; + head->ObtainInventory (self); + } + head->pitch = 0; + head->RenderStyle = self->RenderStyle; + head->alpha = self->alpha; + if (head->player->camera == self) + { + head->player->camera = head; + } } } diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index d37869a68f..207c35cec7 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -647,10 +647,10 @@ AInventory *AInventory::CreateTossable () { copy->MaxAmount = MaxAmount; copy->Amount = 1; + copy->DropTime = 30; + copy->flags &= ~(MF_SPECIAL|MF_SOLID); Amount--; } - copy->DropTime = 30; - copy->flags &= ~(MF_SPECIAL|MF_SOLID); return copy; }