From: Jeremy Harris Date: Sat, 5 Mar 2016 18:39:14 +0000 (+0000) Subject: Coverity: attempt to quieten null-deref whines about stringhandling X-Git-Tag: exim-4_87_RC6~4 X-Git-Url: https://git.exim.org/users/heiko/exim.git/commitdiff_plain/a1b8a755528674c2ac1652eacb4f2c835f6751b6 Coverity: attempt to quieten null-deref whines about stringhandling --- diff --git a/src/src/string.c b/src/src/string.c index 28d578015..d74787213 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -1086,6 +1086,8 @@ Returns: pointer to the start of the string, changed if copied for expansion. Note that a NUL is not added, though space is left for one. This is because string_cat() is often called multiple times to build up a string - there's no point adding the NUL till the end. + +coverity[+alloc] */ uschar * @@ -1132,8 +1134,14 @@ if (p + count >= *size) /* Because we always specify the exact number of characters to copy, we can use memcpy(), which is likely to be more efficient than strncopy() because the -latter has to check for zero bytes. */ +latter has to check for zero bytes. + +The Coverity annotation deals with the lack of correlated variable tracking; +common use is a null string and zero size and pointer, on first use for a +string being built. The "if" above then allocates, but Coverity assume that +the "if" might not happen and whines for a null-deref done by the memcpy(). */ +/* coverity[var_deref_op] */ memcpy(string + p, s, count); *ptr = p + count; return string;