diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 17:55:27 +0200 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2020-09-17 20:01:29 +0200 |
commit | 6e0fb1ee25efa07be5aef320501f3908f44e5b79 (patch) | |
tree | c0fa9de11ab6e29a02dfbd93676cbc58b0a7599a | |
parent | 66d06b033c3f6eafde901418be3c089ffcc6ebfc (diff) |
Make zero-sized new standards-compliant
This fixes part of #287.
-rw-r--r-- | cores/arduino/new.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp index a36fd21..1683594 100644 --- a/cores/arduino/new.cpp +++ b/cores/arduino/new.cpp @@ -23,6 +23,10 @@ namespace std { } void * operator new(size_t size) { + // Even zero-sized allocations should return a unique pointer, but + // malloc does not guarantee this + if (size == 0) + size = 1; return malloc(size); } void * operator new[](size_t size) { |