[analyzer] strncpy: Special-case a length of 0 to avoid an incorrect warning.
authorJordy Rose <jediknil@belkadan.com>
Mon, 14 May 2012 17:58:35 +0000 (17:58 +0000)
committerJordy Rose <jediknil@belkadan.com>
Mon, 14 May 2012 17:58:35 +0000 (17:58 +0000)
commit459d5f62c29ee20f5e1df1a3d92c7fde1cdb2724
tree1a206f89a8d819a3f8025fa6cdfbefb610069a38
parent77e7b8ede2b87b0be45bc034c0bdde5e299452e9
[analyzer] strncpy: Special-case a length of 0 to avoid an incorrect warning.

We check the address of the last element accessed, but with 0 calculating that
address results in element -1. This patch bails out early (and avoids a bunch
of other work at that).

Fixes PR12807.

llvm-svn: 156769
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/string.c