bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] src/sort.c: assert on saved.text before calling memcpy()


From: Kamil Dudka
Subject: Re: [PATCH] src/sort.c: assert on saved.text before calling memcpy()
Date: Wed, 6 Jan 2010 22:29:58 +0100
User-agent: KMail/1.9.10

On Wednesday 06 of January 2010 09:36:01 Kovarththanan Rajaratnam wrote:
> @@ -2432,6 +2432,7 @@ mergefps (struct sortfile *files, size_t ntemps,
> size_t nfiles, saved.text = xrealloc (saved.text, savealloc);
>                  }
>                saved.length = smallest->length;
> +              assert(saved.text);
>                memcpy (saved.text, smallest->text, saved.length);
>                if (key)
>                  {

The patch does not solve anything as the assertion may disappear when not 
compiling a debug build anyhow. Generally a proper fix is to ensure the 
program logic never allows a NULL pointer as the memcpy() arg (even when
not debugging) ... but it has been IMO already done.

Can I somehow ask clang to give a probable counterexample for each such a 
warning? Perhaps at least local only to the surrounding function? I think
it would help to prevent false alarms like this.

Kamil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]