summaryrefslogtreecommitdiffstats
path: root/src/basic/alloc-util.h
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-10-13 10:45:14 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-13 12:34:32 +0200
commitfd8879498d50b19c5abd0a90daa8f87be6ff6e9f (patch)
tree9c3d4711ba8b53fac92f9f42164076216141946b /src/basic/alloc-util.h
parentman: systemctl: clarify that --lines=0 is allowed (#10375) (diff)
downloadsystemd-fd8879498d50b19c5abd0a90daa8f87be6ff6e9f.tar.xz
systemd-fd8879498d50b19c5abd0a90daa8f87be6ff6e9f.zip
Revert "alloc-util: return NULL if 0-sized allocation is requested"
This reverts commit c05107767b589e9aac9711eb385738887f86eb77.
Diffstat (limited to 'src/basic/alloc-util.h')
-rw-r--r--src/basic/alloc-util.h5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h
index 62b591117b..ebe42889ea 100644
--- a/src/basic/alloc-util.h
+++ b/src/basic/alloc-util.h
@@ -52,11 +52,8 @@ static inline void freep(void *p) {
#define _cleanup_free_ _cleanup_(freep)
-/* Checks the size arguments of allocation functions for overflow in multiplication. In addition, checks if either of
- * them is 0; that is almost certainly an error (e.g., an overflow in computing _need_), so it's better to fail (and
- * we cannot leave this check to malloc, because the behavior of malloc(0) is impl. specific). */
static inline bool size_multiply_overflow(size_t size, size_t need) {
- return _unlikely_(need == 0 || size == 0 || size > (SIZE_MAX / need));
+ return _unlikely_(need != 0 && size > (SIZE_MAX / need));
}
_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t size, size_t need) {