Fix out-of-range write to the keys[] array, caused by fake SDL_KEY* events.
Pressing the Windows key no longer crashes the Linux build. This was SVN commit r2814.
This commit is contained in:
parent
fff184b8fb
commit
c92c9376b9
@ -28,7 +28,7 @@ extern "C" {
|
||||
#define REAL_GL_1_2
|
||||
#endif
|
||||
#ifdef GL_VERSION_1_3
|
||||
#define REAL_GL_1_3
|
||||
//#define REAL_GL_1_3
|
||||
#endif
|
||||
|
||||
#undef GL_GLEXT_PROTOTYPES
|
||||
|
@ -184,12 +184,17 @@ static void alc_shutdown()
|
||||
{
|
||||
if(alc_ctx)
|
||||
{
|
||||
debug_printf("alcMakeContextCurrent(0)\n");
|
||||
alcMakeContextCurrent(0);
|
||||
debug_printf("alcDestroyContext\n");
|
||||
alcDestroyContext(alc_ctx);
|
||||
}
|
||||
|
||||
if(alc_dev)
|
||||
{
|
||||
debug_printf("alcCloseDevice\n");
|
||||
alcCloseDevice(alc_dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -515,16 +520,22 @@ static void al_shutdown()
|
||||
// .. free all active sounds so that they release their source.
|
||||
// the SndData reference is also removed,
|
||||
// but these remain open, since they are cached.
|
||||
debug_printf("list_free_all\n");
|
||||
list_free_all();
|
||||
|
||||
// .. actually free all (still cached) SndData instances.
|
||||
debug_printf("hsd_list_free_all\n");
|
||||
hsd_list_free_all();
|
||||
|
||||
// .. all sources and buffers have been returned to their suballocators.
|
||||
// now free them all.
|
||||
debug_printf("al_src_shutdown\n");
|
||||
al_src_shutdown();
|
||||
|
||||
debug_printf("al_buf_shutdown\n");
|
||||
al_buf_shutdown();
|
||||
|
||||
debug_printf("alc_shutdown\n");
|
||||
alc_shutdown();
|
||||
|
||||
al_initialized = false;
|
||||
|
@ -73,7 +73,9 @@ static int MainInputHandler(const SDL_Event* ev)
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
c = ev->key.keysym.sym;
|
||||
keys[c] = (ev->type == SDL_KEYDOWN);
|
||||
// Prevent out-of-range writes on faked key events
|
||||
if (c < SDLK_LAST)
|
||||
keys[c] = (ev->type == SDL_KEYDOWN);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
|
Loading…
Reference in New Issue
Block a user