clang detected the following false positive:

sort.c:2946:3: warning: Pass-by-value argument in function call is undefined
  free (buf.buf);
  ^     ~~~~~~~

src/sort.c: Add an assert indicating that sort() is always called with nfiles > 
0. This allows clang to deduce that 'buf.buf' is always set/valid.

Signed-off-by: Kovarththanan Rajaratnam <kovarththanan.rajarat...@gmail.com>
---
 src/sort.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index 9c25723..039df13 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2874,6 +2874,8 @@ sort (char * const *files, size_t nfiles, char const 
*output_file)
 
   buf.alloc = 0;
 
+  assert(nfiles > 0);
+
   while (nfiles)
     {
       char const *temp_output;
-- 
1.6.3.3



Reply via email to