>From c65f5323d2c187e01e73c7a074382f77ff8ee708 Mon Sep 17 00:00:00 2001
From: Kovarththanan Rajaratnam <kovarththanan.rajarat...@gmail.com>
Date: Tue, 5 Jan 2010 20:24:02 +0100
Subject: [PATCH] src/sort.c: assert on temp.text before calling memcpy()

clang detected the following false positive:

sort.c:2292:7: warning: Null pointer passed as an argument to a 'nonnull' parameter
      memcpy (temp.text, line->text, line->length);

When we reach this line temp.text is guaranteed to be non null.
---
 src/sort.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index 481fdb8..b50f6cd 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <signal.h>
+#include <assert.h>
 #include "system.h"
 #include "argmatch.h"
 #include "error.h"
@@ -2289,6 +2290,7 @@ check (char const *file_name, char checkonly)
 
           temp.text = xrealloc (temp.text, alloc);
         }
+      assert(temp.text);
       memcpy (temp.text, line->text, line->length);
       temp.length = line->length;
       if (key)
-- 
1.6.3.3

Reply via email to