Commit graph

3796 commits

Author SHA1 Message Date
Sam Lantinga
a438cbd7fe Fixed bug 1804 - Memory leak issue in src/video/x11/SDL_x11mouse.c
Nitz

In SDL_x11mouse.c file there is function named
static Cursor
X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
{
  // Some code

  data_bits = SDL_calloc(1, surface->h * width_bytes);
  mask_bits = SDL_calloc(1, surface->h * width_bytes);
  if (!data_bits || !mask_bits) {
     SDL_OutOfMemory();
     return None;
  }

 // Some code

}

Here is the problem in if statement,
suppose if !data_bits is false and !mask_bits is true then,
data_bits will go out of scope and leaks the memory it points to.

Solution is that data_bits and mask_bits should be checked separately, not by using OR operator.
2013-04-17 01:35:10 -07:00
Sam Lantinga
eb97bff0bd Fixed bug 1802 - NULL pointer dereference in SDL_AllocRW() if out of memory.
Philipp Wiesemann

There is a NULL pointer dereference in SDL_AllocRW() if the system is out of memory. The "type" field is always written. This may be fixed with an early return.

Or an else{} or not writing the field and using slower SDL_calloc().

This fault was recently introduced (http://hg.libsdl.org/SDL/rev/681820ca0e78).
2013-04-17 01:32:06 -07:00
Sam Lantinga
226fdc16e6 BMP files don't contain alpha information in the palette, the fourth element is reserved and must be zero. 2013-04-16 09:33:33 -07:00
Jørgen P. Tjernø
4bf8e7bd24 Numlock & pause fix from Alfred.
Fix numlock and pause keys not being pressable on win32, they both report under
the same scancode, so use the VK to tell them apart

--HG--
extra : histedit_source : ea129a468bd8ca3164b1aaea0fa143cf2e130b7b
2013-04-10 14:11:26 -07:00
Ryan C. Gordon
280675858c Fixed another infinite recursion accident in stdlib. 2013-04-05 16:34:59 -04:00
Jørgen P. Tjernø
cbd1884115 Add 3 Logitech gamecontroller mappings for Mac OS X. 2013-04-03 16:48:20 -07:00
Ryan C. Gordon
b58d643086 Compiler warning fixes for Windows message box code. 2013-04-03 11:48:03 -04:00
Ryan C. Gordon
7ffbc59786 Fixed compiler warnings. "leftFingerDown" doesn't need to be an SDL_FingerID. 2013-04-03 11:34:21 -04:00
Ryan C. Gordon
6bcac2ad67 Fixed infinite recursion (thanks, Rainer!). 2013-04-03 10:36:15 -04:00
Jørgen P. Tjernø
4926901d46 Add new controller mappings for Windows. 2013-04-02 18:09:30 -07:00
Andreas Schiffler
2b26967375 Add input validation and null checking to SDL_Get/SetWindowData [reported by Joseph T.] 2013-04-02 08:38:52 -07:00
Sam Lantinga
d197d674be Fixed bug 1780 - SDL_RWFromFile() sets an error on Android although a valid SDL_RWops pointer is returned.
Philipp Wiesemann

SDL_RWFromFile() sets an error to be queried with SDL_GetError() on Android although a valid SDL_RWops pointer is returned.

This happens if the fallback implemented in SDL_android.cpp is used to load compressed assets (see README.android in section "Loading assets") and results in a message like "java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed". I think this is confusing and not needed because the loading works as expected.

I attached a patch which changes SDL_android.cpp to not set an error if compressed assets are loaded. In this case also no Exception is queried and no additional string are created.
2013-04-02 07:57:37 -07:00
Sam Lantinga
3bdfec9df0 Fixed bug 1781 - SDL sets an error for the initial touch on Android.
Philipp Wiesemann

SDL sets an error to be queried with SDL_GetError() for the initial touch on Android.

Android_OnTouch() in SDL_androidtouch.c uses SDL_GetTouch() to check if a touch device was already added. SDL_GetTouch() sets the error "Unknown touch device" for an out of range access because touch devices are added after initial touch. I think this error is confusing because it always happens by design.

I attached a patch which removes the call to SDL_GetTouch() and only uses SDL_AddTouch() which does the check (if already added) again and does not set an error (if not added yet).
2013-04-02 07:51:23 -07:00
Gabriel Jacobo
b39dd8c4e3 Backed out changeset: a500a9dbfb41 2013-04-01 13:21:23 -03:00
Gabriel Jacobo
0bc9621a7f Backed out changeset: a713101e1d25 2013-04-01 13:21:08 -03:00
Gabriel Jacobo
6fe4eabf3e Backed out changeset: 9cef1005df5f 2013-04-01 13:20:22 -03:00
Ryan C. Gordon
2df4ed556e Changed audio subsystem's OpenDevice interface to return -1 on error.
This lets us 'return SDL_SetError("whatever");' on one line.

 Fixes Bugzilla #1778.
2013-03-31 13:05:40 -04:00
Ryan C. Gordon
4f438b70a2 Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
2013-03-31 12:48:50 -04:00
Ryan C. Gordon
d7b0215c79 Haiku no longer #defines __BEOS__, so check for it too (thanks, Axel!).
Fixes Bugzilla #1773.
2013-03-29 21:25:02 -04:00
Sam Lantinga
75a30e72a0 Fixed compiler error with Cygwin 2013-03-26 05:09:09 -07:00
Sam Lantinga
607bf8a77c Fixed compiler warning with Cygwin 2013-03-26 05:08:57 -07:00
Sam Lantinga
1e10688f01 SDL message box improvements from Dan Thompson 2013-03-26 04:57:29 -07:00
Sam Lantinga
aff63d09c2 Added support for the GameStop Gamepad 2013-03-25 12:04:16 -07:00
Sam Lantinga
abfb78058f Added GUIDs for Bluetooth devices, using the same algorithm as the Linux code.
Reformatted the code so it was easier to step through using gdb.
2013-03-25 11:38:30 -07:00
Sam Lantinga
8718681e49 Make sure we bump the palette version when we modify it. 2013-03-24 10:37:16 -07:00
Sam Lantinga
e09b99c523 We're using the alpha component of the palette entries, let's name it appropriately. 2013-03-24 09:56:45 -07:00
Sam Lantinga
8f9ae94235 The palette unused value is treated as alpha and updated when setting the colorkey.
This fixes issues loading palettized images that have a colorkey with the same RGB values as another entry in the palette (e.g. bug 1746)
2013-03-24 09:51:01 -07:00
Sam Lantinga
404d8c5429 Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard. 2013-03-22 11:42:31 -07:00
Sam Lantinga
3f660cc9ad Removed old file from the Android build 2013-03-19 23:24:24 -07:00
Sam Lantinga
6dddee5200 Added missing files for the Android build 2013-03-19 23:07:49 -07:00
Sam Lantinga
3c610adc98 Fixed bug 1700 - Joysticks not supported in Android 2013-03-19 23:03:57 -07:00
Sam Lantinga
fecccf1718 Fixed bug 1763 - Constify SDL_UpdateWindowSurfaceRects()
Ryan C. Gordon

With this function...
   SDL_UpdateWindowSurfaceRects(SDL_Window * window, SDL_Rect * rects, int numrects);
...is there any reason rects isn't "const SDL_Rect *" ?
2013-03-19 21:53:33 -07:00
Sam Lantinga
3afbe992d5 Removed Nintendo DS support since nobody has volunteered to maintain it for over a year. 2013-03-17 09:44:58 -07:00
Captain Lex
47dac69dc7 Add PSP support 2013-03-17 20:07:02 +08:00
Sam Lantinga
6509d6080b Fixed XIM crash when locale is set to something not supported by X11. 2013-03-15 11:59:16 -07:00
Ryan C. Gordon
7e934f8f75 Improvements to stdlib.
All SDL_* functions are always available as real symbols, so you can always
link against them as a stable ABI. By default, however, all the things that
might have dithered down to macros in your application are now force-inlined,
to give you the same effect as before and theoretically better performance,
but still solve the classic macro problems.

Elsewhere, we provide real functions for these things that simply wrap the
inline functions, in case one needs to have a real function available.

Also: this exposed bugs: SDL_abs() does something different if you had the
macro vs the libc function, SDL_memcpy() returns a void* in the function
but not the macro, etc.
2013-03-15 01:01:20 -04:00
Sam Lantinga
124288fdb9 XDnD implementation from Davey Taylor, need some cleanup 2013-03-13 21:41:43 -07:00
Andreas Schiffler
42a673ce23 Fix bug 122 - SDL_RWops bug fixes: set RWops.type field, add input validation, add test coverage 2013-03-13 08:35:03 -07:00
Jørgen P. Tjernø
ae480eecfd Missing comma in one gamepad mapping. 2013-03-12 18:28:40 -07:00
Jørgen P. Tjernø
fc436807a8 Add GameController mappings for popular controllers.
This adds mappings for:
  - Another type of wired X360 controller
  - A wireless X360 controller
  - Logitech F710 (XInput and DInput modes)
  - Logitech F310 (XInput mode)
  - Logitech Cordless RumblePad 2
2013-03-12 18:28:36 -07:00
Andreas Schiffler
6a2bff0cd1 Fix bug 1560 - SDL_RWFromConstMem write operation returns -1 but should return 0. 2013-03-12 09:10:37 -07:00
Sam Lantinga
f25403ba28 Fixed bug 1751 - Direcftb renderer viewport behaviour differs from API description.
tomaszewski.p

According to API description:
SDL_RenderSetViewport - Use this function to set the drawing area for rendering on the current target.

DirectFB renderer in DirectFB_UpdateViewport function just sets clip on surface, instead of moving drawing area.

Attached patch uses set clip rectangle to move {x,y} coordinates during draw and blit operations to be compatible with API description.
2013-03-10 21:10:10 -07:00
Ryan C. Gordon
8181152c53 Patched to compile on Visual Studio. 2013-03-10 13:36:20 -04:00
Ryan C. Gordon
f34606e325 Fixed compiler warning. 2013-03-10 13:31:55 -04:00
Ryan C. Gordon
2e19fefe52 Attempt to get XInput haptics building on Cygwin (or rather, avoid building). 2013-03-10 13:28:39 -04:00
Ryan C. Gordon
3d572bdf89 First shot at Windows XInput haptics.
--HG--
extra : rebase_source : 52e691a0917d173e891e67714a135373daea0ef5
2013-03-10 13:05:47 -04:00
Sam Lantinga
203b9839d2 Fixed bug 1750 - Directfb renderer does not support SDL_RENDERER_TARGETTEXTURE
tomaszewski.p

DirectFB renderer does not support SDL_RENDERER_TARGETTEXTURE what makes it incompatible with GL or GLES(2) renderers.

Attached patched:
- adds support for SDL_RENDERER_TARGETTEXTURE,
- DirectFB RenderCopy converts destination rectangle from floats to ints,
- fixes whitespaces to be the same in whole file.
2013-03-10 09:09:31 -07:00
Sam Lantinga
2422c520ac Fixed bug 1749 - SDL_GL_CreateContext() causes fatal X11 protocol errors that should just be caught instead
Lee Salzman

When using SDL_GL_CreateContext() to create a >= 3.0 version or core/forward-compatible context, internally glXCreateContextAttribsARB is used. Mesa in particular seems to be having trouble with this call and returning all sorts of errors, so it is dangerous to poll for the highest GL version by using calls to SDL_GL_CreateContext unless you are sure, a priori, that the call will suceed, defeating the point of its use.

X11 protocol errors are of the following form, with varying details depending on user, but the cause is always SDL_GL_CreateContext as above...

X Error of failed request:  GLXBadFBConfig
  Major opcode of failed request:  153 (GLX)
  Minor opcode of failed request:  34 ()
  Serial number of failed request:  215
  Current serial number in output stream:  221

These sorts of errors can be temporarily filtered out by setting an X11 error handler to catch and ignore them, which is safe with respect to SDL_GL_CreateContext behavior because this function is allowed to return NULL to indicate failure.

A patch is attached to do this temporary filtering/catching of errors generated by trying to use glXCreateContextAttribs and friends...
2013-03-10 09:07:23 -07:00
Sam Lantinga
7ce1b4475f Fixed bug 1744 - DirectFB video and renderer API is not updated
tomaszewski.p

Recent changes in SDL_sysrenderer.h and SDL_sysvideo.h had no impact on directfb backend.

Attached patch:
- updates interface,
- resolves uninitialized variable reading,
- changes logging tio use SDL_Log API,
- updates configure to use DIRECTFBCONFIG variable instead direct call to directfb-config.
2013-03-09 10:35:12 -08:00
Andreas Schiffler
c51712467d Fix SDL_TryLockMutex compile error when FAKE_RECURSIVE_MUTEX is defined 2013-03-09 09:24:43 -08:00