diff options
| author | Ray <[email protected]> | 2024-07-01 13:06:15 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2024-07-01 13:06:15 +0200 |
| commit | 2bc75b877a253f496696c1b870483ed919d4e709 (patch) | |
| tree | 4f28cd7c12f5a1bc678fd4cd059d2e6cb5313595 | |
| parent | a1d516354e5bf85ddfff3293172bb6c0f8e853ec (diff) | |
| download | raylib-2bc75b877a253f496696c1b870483ed919d4e709.tar.gz raylib-2bc75b877a253f496696c1b870483ed919d4e709.zip | |
WARNING: TEST: Security check to address potential overflow cocerns
| -rw-r--r-- | src/raylib.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/raylib.h b/src/raylib.h index 2c7a6a57..ebc7fe55 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -123,11 +123,12 @@ // Allow custom memory allocators // NOTE: Require recompiling raylib sources +#define MAX_ALLOC_SIZE 1024*1024 // 1GB of maximum allocation data #ifndef RL_MALLOC - #define RL_MALLOC(sz) malloc(sz) + #define RL_MALLOC(sz) ((sz > MAX_ALLOC_SIZE)? malloc(sz) : NULL) #endif #ifndef RL_CALLOC - #define RL_CALLOC(n,sz) calloc(n,sz) + #define RL_CALLOC(n,sz) ((n*sz > MAX_ALLOC_SIZE)? calloc(n,sz) : NULL) #endif #ifndef RL_REALLOC #define RL_REALLOC(ptr,sz) realloc(ptr,sz) |
