mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
include: Assert that "count * size" does not overflow in vkd3d_calloc().
This commit is contained in:
parent
bc1c2bcadf
commit
ed50a4e7f5
@ -23,6 +23,7 @@
|
|||||||
#ifndef __VKD3D_MEMORY_H
|
#ifndef __VKD3D_MEMORY_H
|
||||||
#define __VKD3D_MEMORY_H
|
#define __VKD3D_MEMORY_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include "vkd3d_debug.h"
|
#include "vkd3d_debug.h"
|
||||||
|
|
||||||
static inline void *vkd3d_malloc(size_t size)
|
static inline void *vkd3d_malloc(size_t size)
|
||||||
@ -43,6 +44,7 @@ static inline void *vkd3d_realloc(void *ptr, size_t size)
|
|||||||
static inline void *vkd3d_calloc(size_t count, size_t size)
|
static inline void *vkd3d_calloc(size_t count, size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
assert(count <= ~(size_t)0 / size);
|
||||||
if (!(ptr = calloc(count, size)))
|
if (!(ptr = calloc(count, size)))
|
||||||
ERR("Out of memory.\n");
|
ERR("Out of memory.\n");
|
||||||
return ptr;
|
return ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user