Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed|Map Renderer|Client|Debug: Crash attempting to sort vissprites
If rend-dev-freeze 1 was set prior to starting a map, no vissprites
were generated during the first frame, meaning visSpriteP == NULL,
thus when subtracted from visSprites yielded an completely incorrect
count of the number of vissprites in use.

Consequently, R_SortVisSprites() trashed whatever happened to be in
memory following the fixed-size visSprites array and utterly confused
itself when trying to sort the results. Ultimately causing a crash
when it attempted to deference an invalid pointer.
  • Loading branch information
danij-deng committed Dec 4, 2014
1 parent cd076d3 commit 866c47b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_main.cpp
Expand Up @@ -3585,7 +3585,7 @@ static void drawMasked()

R_SortVisSprites();

if(visSpriteP > visSprites)
if(visSpriteP && visSpriteP > visSprites)
{
bool primaryHaloDrawn = false;

Expand Down
4 changes: 3 additions & 1 deletion doomsday/client/src/render/vissprite.cpp
Expand Up @@ -117,7 +117,9 @@ void VisSprite_SetupModel(vissprite_t *spr,

void R_SortVisSprites()
{
int count = visSpriteP - visSprites;
if(!visSpriteP) return;

int const count = visSpriteP - visSprites;
if(!count) return;

vissprite_t unsorted;
Expand Down

0 comments on commit 866c47b

Please sign in to comment.