summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-20 17:53:03 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-20 17:53:03 +0200
commitaa408e7799cf01f048efedf434916544b4badc77 (patch)
treec0aa91be952b32c6e05006fe825b180a8c85e503 /src/shared/util.h
parent3f8cc098d218525710e5cbad9adf37001d3b6060 (diff)
util: fix overflow checks
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index 2e49cfde2e..e1d4735ee3 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -545,14 +545,14 @@ void closedirp(DIR **d);
void umaskp(mode_t *u);
_malloc_ static inline void *malloc_multiply(size_t a, size_t b) {
- if (_unlikely_(a > ((size_t) -1) / b))
+ if (_unlikely_(b == 0 || a > ((size_t) -1) / b))
return NULL;
return malloc(a * b);
}
_malloc_ static inline void *memdup_multiply(const void *p, size_t a, size_t b) {
- if (_unlikely_(a > ((size_t) -1) / b))
+ if (_unlikely_(b == 0 || a > ((size_t) -1) / b))
return NULL;
return memdup(p, a * b);