On Fri, Oct 21, 2011 at 12:31 PM, Markus Armbruster <arm...@redhat.com> wrote: > Paolo Bonzini <pbonz...@redhat.com> writes: > >> On 10/20/2011 07:23 PM, Stefan Hajnoczi wrote: >>> On Tue, Oct 18, 2011 at 09:17:35PM +0400, Pavel Borzenkov wrote: >>>> Spotted by Clang Analyzer >>>> >>>> Signed-off-by: Pavel Borzenkov<pavel.borzen...@gmail.com> >>>> --- >>>> block/qed.c | 6 ++++-- >>>> 1 files changed, 4 insertions(+), 2 deletions(-) >>> >>> Thanks, applied to the trivial patches tree: >>> http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches >> >> I think there are other places in the tree where we assume that >> "memcpy(dest, NULL, 0);" works. > > Looks like a fair assumption to me. >
Such calls work, but this is UB. Calling string functions with NULL pointers and zero length is a violation of the C99 standard: 7.21.1 String function conventions Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4. -- Pavel