aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/new.cpp4
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) {