Fix Bug 2021: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console; fix off-by-one error in SDLtest test suite
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Thu, 08 Aug 2013 21:29:30 -0700
changeset 7614af0bd07212bd
parent 7613 27e0ae109c71
child 7615 90ff13467550
Fix Bug 2021: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console; fix off-by-one error in SDLtest test suite
src/SDL_log.c
test/testautomation_sdltest.c
     1.1 --- a/src/SDL_log.c	Thu Aug 08 21:16:29 2013 -0700
     1.2 +++ b/src/SDL_log.c	Thu Aug 08 21:29:30 2013 -0700
     1.3 @@ -317,6 +317,7 @@
     1.4  {
     1.5  #if defined(__WIN32__)
     1.6      /* Way too many allocations here, urgh */
     1.7 +    /* Note: One can't call SDL_SetError here, since that function itself logs. */
     1.8      {
     1.9          char *output;
    1.10          size_t length;
    1.11 @@ -331,16 +332,16 @@
    1.12              if (!attachResult) {
    1.13                      attachError = GetLastError();
    1.14                      if (attachError == ERROR_INVALID_HANDLE) {
    1.15 -                        SDL_SetError("Parent process has no console");
    1.16 +                        OutputDebugString(TEXT("Parent process has no console"));
    1.17                          consoleAttached = -1;
    1.18                      } else if (attachError == ERROR_GEN_FAILURE) {
    1.19 -                         SDL_SetError("Could not attach to console of parent process");
    1.20 +                         OutputDebugString(TEXT("Could not attach to console of parent process"));
    1.21                           consoleAttached = -1;
    1.22                      } else if (attachError == ERROR_ACCESS_DENIED) {  
    1.23                           /* Already attached */
    1.24                          consoleAttached = 1;
    1.25                      } else {
    1.26 -                        SDL_SetError("Error %d attaching console", attachError);
    1.27 +                        OutputDebugString(TEXT("Error attaching console"));
    1.28                          consoleAttached = -1;
    1.29                      }
    1.30                  } else {
    1.31 @@ -364,10 +365,10 @@
    1.32          /* Screen output to stderr, if console was attached. */
    1.33          if (consoleAttached == 1) {
    1.34                  if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
    1.35 -                    SDL_SetError("Error %d calling WriteConsole", GetLastError());
    1.36 +                    OutputDebugString(TEXT("Error calling WriteConsole"));
    1.37                  }
    1.38                  if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) {
    1.39 -                    SDL_SetError("Insufficient heap memory to write message of size %d", length);
    1.40 +                    OutputDebugString(TEXT("Insufficient heap memory to write message"));
    1.41                  }
    1.42          }
    1.43  
     2.1 --- a/test/testautomation_sdltest.c	Thu Aug 08 21:16:29 2013 -0700
     2.2 +++ b/test/testautomation_sdltest.c	Thu Aug 08 21:29:30 2013 -0700
     2.3 @@ -63,7 +63,7 @@
     2.4    SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
     2.5  
     2.6    result = (Sint64)SDLTest_RandomSint8();
     2.7 -  min = 1 - (1 << 7);
     2.8 +  min = 0 - (1 << 7);
     2.9    max =     (1 << 7) - 1;
    2.10    SDLTest_AssertPass("Call to SDLTest_RandomSint8");
    2.11    SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
    2.12 @@ -74,7 +74,7 @@
    2.13    SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
    2.14  
    2.15    result = (Sint64)SDLTest_RandomSint16();
    2.16 -  min = 1 - (1 << 15);
    2.17 +  min = 0 - (1 << 15);
    2.18    max =     (1 << 15) - 1;
    2.19    SDLTest_AssertPass("Call to SDLTest_RandomSint16");
    2.20    SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);
    2.21 @@ -85,7 +85,7 @@
    2.22    SDLTest_AssertCheck(result >= 0 && result <= (Sint64)umax, "Verify result value, expected: [0,%llu], got: %lld", umax, result);
    2.23  
    2.24    result = (Sint64)SDLTest_RandomSint32();
    2.25 -  min = 1 - ((Sint64)1 << 31);
    2.26 +  min = 0 - ((Sint64)1 << 31);
    2.27    max =     ((Sint64)1 << 31) - 1;
    2.28    SDLTest_AssertPass("Call to SDLTest_RandomSint32");
    2.29    SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%lld,%lld], got: %lld", min, max, result);