Skip to content

Commit

Permalink
atari:xbios: We align pointer on a 256-byte boundary, so we need to a…
Browse files Browse the repository at this point in the history
…llocate enough to avoid potential out of bounds access
  • Loading branch information
pmandin committed Sep 22, 2017
1 parent 2e39f67 commit b28d5be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/video/xbios/SDL_xbios_f30.c
Expand Up @@ -282,13 +282,13 @@ static int allocVbuffers_SV(_THIS, int num_buffers, int bufsize)
Uint32 tmp;

for (i=0; i<num_buffers; i++) {
XBIOS_screensmem[i] = Atari_SysMalloc(bufsize, MX_STRAM);
XBIOS_screensmem[i] = Atari_SysMalloc(bufsize+256, MX_STRAM);

if (XBIOS_screensmem[i]==NULL) {
SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
return (0);
}
SDL_memset(XBIOS_screensmem[i], 0, bufsize);
SDL_memset(XBIOS_screensmem[i], 0, bufsize+256);

/* Align on 256byte boundary and map to Supervidel memory */
tmp = ( (Uint32) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL;
Expand Down
4 changes: 2 additions & 2 deletions src/video/xbios/SDL_xbios_st.c
Expand Up @@ -157,13 +157,13 @@ static int allocVbuffers(_THIS, int num_buffers, int bufsize)
int i;

for (i=0; i<num_buffers; i++) {
XBIOS_screensmem[i] = Atari_SysMalloc(bufsize, MX_STRAM);
XBIOS_screensmem[i] = Atari_SysMalloc(bufsize+256, MX_STRAM);

if (XBIOS_screensmem[i]==NULL) {
SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
return (0);
}
SDL_memset(XBIOS_screensmem[i], 0, bufsize);
SDL_memset(XBIOS_screensmem[i], 0, bufsize+256);

XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL);
}
Expand Down

0 comments on commit b28d5be

Please sign in to comment.