1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-05 13:53:38 +00:00
lovr/src/modules
bjorn c9fe026a66 Fix undefined behavior in arr_free;
Currently there is a single allocator function used in arr_t.  Its
behavior depends on the values for the pointer and size arguments:

- If pointer is NULL, it should allocate new memory.
- If pointer is non-NULL and size is positive, it should resize memory.
- If size is zero, it should free memory.

All instances of arr_t use realloc for this right now.  The problem
is that realloc's behavior is undefined when the size argument is zero.
On Windows and Linux, realloc will free the pointer, but on macOS this
isn't the case.  This means that arr_t leaks memory on macOS.

It's best to not rely on undefined behavior like this, so let's instead
use a helper function that behaves the way we want.
2022-03-14 12:27:58 -07:00
..
audio phonon: Fix crash when setGeometry fails; 2021-04-27 22:15:15 -06:00
data Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
event Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
filesystem Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
graphics Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
headset Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
math Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
physics Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
system lovr.system.getCoreCount; 2021-02-25 09:30:05 -07:00
thread Fix undefined behavior in arr_free; 2022-03-14 12:27:58 -07:00
timer lovr.system; 2021-02-25 09:00:12 -07:00