Fixed stack smashing crash when using the GCC compiled DLL with Visual Studio.
authorSam Lantinga <slouken@libsdl.org>
Mon, 29 Jul 2013 23:28:25 -0700
changeset 7546 f9ff5e066e49
parent 7545 adb619b0af9c
child 7547 abdea1385dbb
Fixed stack smashing crash when using the GCC compiled DLL with Visual Studio.
include/SDL_audio.h
--- a/include/SDL_audio.h	Tue Jul 30 01:32:26 2013 -0400
+++ b/include/SDL_audio.h	Mon Jul 29 23:28:25 2013 -0700
@@ -183,6 +183,17 @@
 /**
  *  A structure to hold a set of audio conversion filters and buffers.
  */
+#ifdef __GNUC__
+/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't
+   pad it out to 88 bytes to guarantee ABI compatibility between compilers.
+   vvv
+   The next time we rev the ABI, make sure to size the ints and add padding.
+*/
+#define SDL_AUDIOCVT_PACKED __attribute__((packed))
+#else
+#define SDL_AUDIOCVT_PACKED
+#endif
+/* */
 typedef struct SDL_AudioCVT
 {
     int needed;                 /**< Set to 1 if conversion possible */
@@ -196,7 +207,7 @@
     double len_ratio;           /**< Given len, final size is len*len_ratio */
     SDL_AudioFilter filters[10];        /**< Filter list */
     int filter_index;           /**< Current audio conversion function */
-} SDL_AudioCVT;
+} SDL_AUDIOCVT_PACKED SDL_AudioCVT;
 
 
 /* Function prototypes */