src/stdlib


Log

Author Commit Date CI Message
Ryan C. Gordon d4086e4a 2017-05-29T03:01:05 stdlib: added SDL_utf8strlen().
Ryan C. Gordon 29a047df 2017-05-29T00:51:38 Fixed whitespace code style.
Ryan C. Gordon c93bca48 2017-02-14T02:49:08 stdlib: Fixed crash on SDL_snprintf("%s", NULL). Like other C runtimes, it should probably produce the string "(null)". This bug probably only affected Windows, as most platforms use their standard C runtime's snprintf().
Sam Lantinga 5cb1ca55 2017-01-18T11:57:27 Fixed building with mingw32
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 880842cf 2016-12-31T16:14:51 Fixed bug 3531 - internal SDL_vsnprintf implementation access memory outside given buffer ranges Tristan The internal SDL_vsnprintf implementation accesses memory outside buffer. The bug existed also inside the format (%) processing, which was fixed with Bug 3441. But there is still an invalid access, if we do not have any format inside the source string and the destination string is shorter than the format string. You can use any string for this test, as long it is longer than the buffer. Example: va_list argList; char buffer[4]; SDL_vsnprintf(buffer, sizeof(buffer), "Testing", argList); The bug is located on the 'else' branch of the format char test: while (*fmt) { if (*fmt == '%') { ... } else { if (left > 1) { *text = *fmt; --left; } ++fmt; ++text; } } if (left > 0) { *text = '\0'; } As you can see that text is always incremented, even when left is already one. When then on the last lines, *text is assigned the NULL char, the pointer is located outside bounds.
Ryan C. Gordon 232ae688 2016-11-23T17:20:28 Still more compiler warning fixes for various platforms.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga 74e1dd4c 2016-11-11T13:14:00 Define _GNU_SOURCE when building SDL
Sam Lantinga 79f6ba5a 2016-11-11T03:18:16 Fixed signed/unsigned comparison warnings in Visual Studio
Sam Lantinga 40b571c9 2016-11-06T10:01:08 Fixed bug 3468 - _allshr in SDL_stdlib.c is not working properly Mark Pizzolato On Windows with Visual Studio, when building SDL as a static library using the x86 (32bit) mode, several intrinsic operations are implemented in code in SDL_stdlib.c. One of these, _allshr() is not properly implemented and fails for some input. As a result, some operations on 64bit data elements (long long) don't always work. I classified this bug as a blocker since things absolutely don't work when the affected code is invoked. The affected code is only invoked when SDL is compiled in x86 mode on Visual Studio when building a SDL as a static library. This build environment isn't common, and hence the bug hasn't been noticed previously. I reopened #2537 and mentioned this problem and provided a fix. That fix is provided again here along with test code which could be added to some of the SDL test code. This test code verifies that the x86 intrinsic routines produce the same results as the native x64 instructions which these routines emulate under the Microsoft compiler. The point of the tests is to make sure that Visual Studio x86 code produces the same results as Visual Studio x64 code. Some of the arguments (or boundary conditions) may produce different results on other compiler environments, so the tests really shouldn't be run on all compilers. The test driver only actually exercised code when the compiler defines _MSC_VER, so the driver can generically be invoked without issue.
Sam Lantinga 8109b137 2016-10-17T21:47:33 Partial fix for bug 3092 - Statically link sdl2 with /MT for msvc Mike Linford I'm also having trouble statically linking SDL2 on Visual Studio 2015 with /MT. My symptom is that memcpy is being defined twice.
Sam Lantinga 9db5e9aa 2016-10-10T02:58:29 Made #if defined(X) consistent
Sam Lantinga 6dedbc43 2016-10-10T02:58:12 Make sure we have iconv.h before building with it
Sam Lantinga 73f2c541 2016-10-07T16:44:42 Fixed bug 2885 - SDL_stdinc.h doesn't need to include iconv.h Ryan C. Gordon We still include iconv.h in SDL_stdinc.h, probably because this header might have referenced the native iconv functions and types directly. Since these are hidden behind a stable ABI now and never just a #define for the system iconv, we shouldn't need this header included from a public SDL header anymore, slowing down external apps compiles and pulling tons of stuff into the namespace.
Ryan C. Gordon 46f44f66 2016-10-04T14:25:31 Fixed potential buffer overflow in SDL_vsnprintf() (thanks, Taylor!). Fixes Bugzilla #3441. "When using internal SDL_vsnprintf(), and source string length is greater than destination, the final NULL char will be written beyond destination size. Primary issue that is SDL_strlcpy returns length of source string (SDL_PrintString()), not how much is written to destination. The destination ptr is then incremented by this length before the sanity check is done. Destination string is properly terminated, but an extra NULL char will be written beyond destination buffer length. Patch used internally is attached which fixes primary issue with SDL_strlcpy() in SDL_PrintString() and adjusts sanity checks to increment destination ptr safely."
Sam Lantinga 5333deab 2016-03-11T08:30:18 Quick fix for qsort off-by-one error.
Ryan C. Gordon 32c70cc5 2016-02-21T13:07:14 stdlib: Restored previous qsort() implementation; the licensing is resolved. Thanks to Gareth McCaughan for changing his code to the zlib license on our behalf!
Ryan C. Gordon 09ae4df5 2016-02-15T03:37:01 Another attempt to fix Windows build.
Ryan C. Gordon 18f74c6e 2016-02-15T03:21:26 Patched to compile on Visual Studio.
Ryan C. Gordon 014956ac 2016-02-15T03:16:46 Replaced SDL_qsort with public domain code from PDCLib: http://pdclib.e43.eu/
Sam Lantinga e2fd1c0f 2016-01-02T11:17:06 Backed out commit 80ce90dbc266, this causes Visual Studio build failure on buildbot
Sam Lantinga ac444cd3 2016-01-02T10:25:53 Fixed bug 3092 - Statically link sdl2 with /MT for msvc Martin Gerhardy According to https://msdn.microsoft.com/de-de/library/2kzt1wy3%28v=vs.120%29.aspx when one is using /MT for msvc compilations the libcmt.lib is already linked to the binary. This lib includes the symbol that is now guarded (see attached patch) by the #ifndef _MT.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Ryan C. Gordon d98cfe14 2015-06-07T20:00:20 Let's assume that if VS2005 and VS2010 do it, VS2008 probably does, too.
Ryan C. Gordon 753f95c5 2015-06-07T19:58:42 VS2005 tweaks (thanks, Ozkan!). Fixes Bugzilla #2895. His notes: The following trivial changes make SDL2 tree (mostly) compatible with Visual Studio 2005: * SDL_stdlib.c: Similar to VS2010 and newer, VS2005 also generates memcpy(), (it also generates memset(), see below), so propagate the #if condition to cover VS2005. * SDL_pixels.c (SDL_CalculateGammaRamp): VS2005 generates a memset() call for gamma==0 case, so replace the if loop with SDL_memset(). * SDL_windowsvideo.h: Include msctf.h only with VS2008 and newer, otherwise include SDL_msctf.h * SDL_windowskeyboard.c: Adjust the #ifdefs so that SDL_msctf.h inclusion is always recognized correctly.
Ryan C. Gordon 75702ffe 2015-05-28T14:34:38 Make sure we have the vsscanf() prototype (thanks, Ozkan!). issue seen with glibc-2.8. Fixes Bugzilla #2721.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
Ryan C. Gordon a823982e 2015-01-05T01:41:42 Clang static analysis builds should use C runtime directly. This is a little macro magic to use malloc() directly instead of SDL_malloc(), etc, so static analysis tests that know about the C runtime can function properly, and understand that we are dealing with heap allocations, etc. This changed our static analysis report from 5 outstanding bugs to 30. 5x as many bugs were hidden by SDL_malloc() not being recognized as malloc() by the static analyzer!
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 1ea86978 2014-08-17T13:11:55 Removed SDL_round() because the license wasn't compatible with zlib
Sam Lantinga 4e7db78e 2014-08-16T23:23:15 Added SDL_round(), contributed by Benoit Pierre - thanks!
Sam Lantinga a0b68e81 2014-07-27T17:44:10 Fixed bug 2537 - _allmul in SDL_lib.c is not working properly
Sam Lantinga 0d673844 2014-06-21T11:52:53 Fixed bug 2596 - SDL_SetError fails on on NULL on systems with vsnprintf sfalexrog On systems with vsnprintf call SDL_SetError fails when passed a NULL as an argument. SDL's implementation checks for NULL (as seen in the commit: https://hg.libsdl.org/SDL/rev/835403a6aec8), but system implementation may crash.
Sam Clegg 7e52722d 2014-06-20T11:10:16 Fix compiler warnings in Native Client and Linux builds.
Sam Lantinga 6101e4b2 2014-06-07T18:20:01 Added SDL_sqrtf(), SDL_tan(), SDL_tanf()
Sam Lantinga 40538446 2014-06-07T17:31:50 Fixed crash with SDL_SetError(NULL)
Sam Lantinga da6d9a9f 2014-06-04T10:56:56 Added annotations to help code analysis tools CR: Bruce Dawson
Yuri Kunde Schlesner d12d7952 2014-05-10T21:48:46 Align pointer in SDL_memset before doing Uint32 loop Some more recent compilers emit SSE aligned store instructions for the loop, causing crashes if the destination buffer isn't aligned on a 32-bit boundary. This would also crash on platforms like ARM that require aligned stores. This fixes a crash inside SDL_FillRect that happens with the official x64 mingw build.
Sam Lantinga 1a4c0dac 2014-05-10T11:27:43 Temporary fix for bug 2494 - Crashes due to the non thread-safe SDL_malloc/SDL_free on Windows We'll define USE_LOCKS as a temporary fix until an alternative like ptmalloc, jemalloc, or nedmalloc can be investigated. http://www.malloc.de/en/ http://www.canonware.com/jemalloc/ http://www.nedprod.com/programs/portable/nedmalloc/ SDL allocates memory very infrequently, so this is probably a decent fix for a while.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Andreas Schiffler f018ca46 2014-03-19T21:39:55 Add input validation to SDL_getenv/SDL_setenv; update Stdlib testsuite; add Hints testsuite
Sam Lantinga 1367bf87 2014-03-09T11:36:47 Integrated David Ludwig's support for Windows RT
Sam Lantinga 7c33f233 2014-02-22T10:40:12 Thou shalt not use more than 4k local variables in this code.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Sam Lantinga 35ab76d0 2013-12-11T21:17:24 Fixed bug 2050 - Obvious bugs in SDL_ltoa and SDL_lltoa pjz SDL_ltoa(-2147483648,s,10) only returns "-" because there is a bug in the code: if ( value < 0 ) { *bufp++ = '-'; value = -value; } but -(-2147483648) is still -2147483648 (0x80000000) as signed int (or long), so the following loop doesn't run at all. Similar bug are also in SDL_lltoa. BTW, there is no sanity check for radix.
Ryan C. Gordon d01ad02b 2013-12-09T15:17:20 Hook up SDL_acos and SDL_asin properly.
Ryan C. Gordon 31caa22d 2013-12-09T13:30:35 Patched stdlib changes to compile on Windows.
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
David Ludwig 46740a5a 2013-11-28T22:09:21 WinRT: merged with latest SDL 2.x/HG code SDL 2.x recently accepted patches to enable OpenGL ES 2 support via Google's ANGLE library. The thought is to try to eventually merge SDL/WinRT's OpenGL code with SDL-official's.
Sam Lantinga 8574c081 2013-11-27T00:29:46 Fixed bug 2274 - SDL_ceil is incorrectly implemented when HAVE_LIBC is not defined Ghassan Al-Mashareqa The SDL_ceil function is implemented incorrectly when HAVE_CEIL is not defined (HAVE_LIBC not defined). The following code: double val = SDL_ceil(2.3); printf("%g", val); prints "2.0", as STD_ceil is defined as: double SDL_ceil(double x) { #ifdef HAVE_CEIL return ceil(x); #else return (double)(int)((x)+0.5); #endif /* HAVE_CEIL */ } This functions is used in the SDL_BuildAudioResampleCVT function of the audio subsystem (SDL_audiocvt.c), and causes a bug in that function.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Ryan C. Gordon e7693740 2013-11-24T23:35:38 Added SDL_vsscanf().
David Ludwig 69c5d21d 2013-10-27T21:26:46 WinRT: merged with SDL 2.0.1 codebase
Sam Lantinga 12ca3ce3 2013-10-17T23:02:29 Fixed building using MinGW Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
Sam Lantinga cefffd61 2013-09-05T06:59:34 Fixed bug 2082 - SDL stdlib implementation does not force upper case for %X format specifier norfanin When SDL_vsnprintf handles the %x format specifier, a boolean is set to signal forced lower case. It also should be able to signal forced upper case for the %X specifier. A boolean is not sufficient anymore. The attached patch adds an enum for the three cases: lower, upper and no change.
Sam Lantinga f79fc33a 2013-08-29T08:29:21 Christoph Mallon: Remove pointless if (x) before SDL_free(x)
David Ludwig d41fdc94 2013-08-13T20:09:52 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.