mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-30 06:58:30 +00:00
Don't create a TLS error buffer if we're just clearing the error
Fixes https://github.com/libsdl-org/SDL/issues/7600
This commit is contained in:
@@ -30,7 +30,7 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
if (fmt) {
|
||||
va_list ap;
|
||||
int result;
|
||||
SDL_error *error = SDL_GetErrBuf();
|
||||
SDL_error *error = SDL_GetErrBuf(SDL_TRUE);
|
||||
|
||||
error->error = SDL_ErrorCodeGeneric;
|
||||
|
||||
@@ -62,7 +62,11 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||
/* Available for backwards compatibility */
|
||||
const char *SDL_GetError(void)
|
||||
{
|
||||
const SDL_error *error = SDL_GetErrBuf();
|
||||
const SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
||||
|
||||
if (!error) {
|
||||
return "";
|
||||
}
|
||||
|
||||
switch (error->error) {
|
||||
case SDL_ErrorCodeGeneric:
|
||||
@@ -76,7 +80,11 @@ const char *SDL_GetError(void)
|
||||
|
||||
void SDL_ClearError(void)
|
||||
{
|
||||
SDL_GetErrBuf()->error = SDL_ErrorCodeNone;
|
||||
SDL_error *error = SDL_GetErrBuf(SDL_FALSE);
|
||||
|
||||
if (error) {
|
||||
error->error = SDL_ErrorCodeNone;
|
||||
}
|
||||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
@@ -84,7 +92,7 @@ int SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
SDL_GetErrBuf()->error = SDL_ErrorCodeOutOfMemory;
|
||||
SDL_GetErrBuf(SDL_TRUE)->error = SDL_ErrorCodeOutOfMemory;
|
||||
return -1;
|
||||
case SDL_EFREAD:
|
||||
return SDL_SetError("Error reading from datastream");
|
||||
|
Reference in New Issue
Block a user