From 1e53274623ab11dd1d48fc26aab2d88abcd94760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 5 Jan 2018 15:40:25 +0100 Subject: [PATCH] Core/MemoryHelper: Fix alloca with a size equivalent to zero --- include/Nazara/Core/MemoryHelper.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index 2788b4ca1..4fb68421e 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -11,6 +11,7 @@ #include +// with MSVC, using alloca with a size of zero returns a valid pointer #define NAZARA_ALLOCA(size) _alloca(size) #define NAZARA_ALLOCA_SUPPORT @@ -18,6 +19,8 @@ #include #define NAZARA_ALLOCA(size) alloca(size) +// with Clang/GCC, using alloca with a size of zero does nothing good +#define NAZARA_ALLOCA(size) alloca(((size) > 0) ? (size) : 1) #define NAZARA_ALLOCA_SUPPORT #endif