Subject: [PATCH 0/5] Miscellaneous fixes from static analysis

From: John Keeping <[email-masked]>
Date: Sun, 16 Feb 2014 16:06:01 +0000

The first two of these fix real bugs, the rest just clean up some of the
less obviously "not actually a problem" issues identified by Clang's
static analyzer [1] and stack[2].

Stack is interesting in that it is designed to detect potentially
undesirable optimizations where undefined behaviour may be being invoked
unwittingly.  It only detected two error's in git.git, the first of
which is fixed by the final patch.  The second it describes as:

	bug: anti-algebra
	model: |
	  %11 = icmp ult i8* %extra_args, %7, !dbg !342
	  -->  %10 = icmp slt i64 %9, 0, !dbg !342
	  ************************************************************
	  %extra_args <u ((sext i32 %buflen to i64) + %extra_args)<nsw>
	  -->  (-1 * (sext i32 %buflen to i64)) <s 0
	stack: 
	  - daemon.c:522:0
	ncore: 1
	core: 
	  - daemon.c:520:0
	    - pointer overflow

which shows that Clang has converted (simplifying from daemon.c:520):

	char *end = extra_args + buflen;
	if (extra_args < end)

into:

	if (buflen < 0)

This doesn't look like it can ever be subject to pointer overflow, so I
have not considered the churn worth it here.

[1] http://clang-analyzer.llvm.org/
[2] https://github.com/xiw/stack

John Keeping (5):
  notes-utils: handle boolean notes.rewritemode correctly
  utf8: fix iconv error detection
  utf8: use correct type for values in interval table
  builtin/mv: don't use memory after free
  streaming: simplify attaching a filter

 builtin/mv.c  | 3 ++-
 notes-utils.c | 2 +-
 streaming.c   | 5 +----
 utf8.c        | 6 +++---
 4 files changed, 7 insertions(+), 9 deletions(-)

-- 
1.9.rc0.187.g6292fff