]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
alloc-util: drop _alloc_(2, 3) decorator from memdup_suffix0_multiply()
authorLennart Poettering <lennart@poettering.net>
Fri, 12 Jul 2019 07:06:28 +0000 (09:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Jul 2019 07:11:40 +0000 (09:11 +0200)
This decorator tells compilers that the memory we return is shorter than
it actually is, thus triggering misleading bad memory access complaints.

Fixes: #13026
src/basic/alloc-util.h

index 9b20be4773ee50e63a35dcabd0c8a86a64f6fec1..cffc737d03ae1896d5993a58de707ca6264b1b8c 100644 (file)
@@ -112,7 +112,9 @@ _alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t size, si
         return memdup(p, size * need);
 }
 
-_alloc_(2, 3) static inline void *memdup_suffix0_multiply(const void *p, size_t size, size_t need) {
+/* Note that we can't decorate this function with _alloc_() since the returned memory area is one byte larger
+ * than the product of its parameters. */
+static inline void *memdup_suffix0_multiply(const void *p, size_t size, size_t need) {
         if (size_multiply_overflow(size, need))
                 return NULL;