Skip to content

Commit

Permalink
Merge pull request #693 from shaneutt/shaneutt/692
Browse files Browse the repository at this point in the history
fix: broken HU_Init due to uninitialized buffer
  • Loading branch information
RobertBeckebans authored Sep 5, 2022
2 parents a0eadeb + 9061b80 commit 2b425ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions doomclassic/doom/f_finale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,8 @@ void F_BunnyScroll (void)
int x;
patch_t* p1;
patch_t* p2;
char name[10];
size_t name_len = 10;
char name[name_len];
int stage;

p1 = (patch_t*)W_CacheLumpName ("PFUB2", PU_LEVEL_SHARED);
Expand Down Expand Up @@ -765,8 +766,8 @@ void F_BunnyScroll (void)
S_StartSound (NULL, sfx_pistol);
::g->laststage = stage;
}
snprintf (name, strlen(name), "END%i",stage);

snprintf(name, name_len, "END%i", stage);
V_DrawPatch ((ORIGINAL_WIDTH-13*8)/2, (ORIGINAL_HEIGHT-8*8)/2,0, (patch_t*)W_CacheLumpName (name,PU_CACHE_SHARED));
}

Expand Down
5 changes: 3 additions & 2 deletions doomclassic/doom/hu_stuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,16 @@ void HU_Init(void)

int i;
int j;
char buffer[9];
size_t buffer_len = 9;
char buffer[buffer_len];

shiftxform = english_shiftxform;

// load the heads-up font
j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++)
{
snprintf(buffer, strlen(buffer), "STCFN%.3d", j++);
snprintf(buffer, buffer_len, "STCFN%03d", j++);
::g->hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC_SHARED);
}

Expand Down

0 comments on commit 2b425ea

Please sign in to comment.