g_clear_pointer may not use the correct calling convention with its callback
g_clear_pointer currently has two definitions. Which one is selected depends on compiler capabilities, like availability of typeof. In case typeof is not available, the destroy callback is cast into a GDestroyNotify pointer, which may not have the same calling convention as the function passed, resulting in potential stack corruption.
How to reproduce: An example would be to call g_clear_pointer(&device, libusb_unref_device). LibUSB declares all its public functions as WINAPI on Windows, which means stdcall calling convention. Compiling this code with GCC for MinGW results in a call to libusb_unref_device using cdecl calling convention instead of stdcall.
This should be fixed, or if not possible, at least documented under which circumstances this can happen.