From 9cad51d00ad27877e7142b9f9ff527a1c36ae63e Mon Sep 17 00:00:00 2001 From: Kihong Heo Date: Thu, 20 Apr 2017 22:46:12 -0700 Subject: [PATCH] [Bufferoverrun] add vector test for cpp Summary: add test for bufferoverrun Reviewed By: jvillard Differential Revision: D4928322 fbshipit-source-id: 2cd1e21 --- infer/tests/codetoanalyze/cpp/checkers/Makefile | 1 + .../cpp/checkers/bufferoverrun/vector.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp diff --git a/infer/tests/codetoanalyze/cpp/checkers/Makefile b/infer/tests/codetoanalyze/cpp/checkers/Makefile index aa6b8906a..b93268b9b 100644 --- a/infer/tests/codetoanalyze/cpp/checkers/Makefile +++ b/infer/tests/codetoanalyze/cpp/checkers/Makefile @@ -23,6 +23,7 @@ SOURCES = \ siof/siof_templated.cpp \ siof/siof_different_tu.cpp \ siof/std_ios_base_init.cpp \ + bufferoverrun/vector.cpp \ HEADERS = siof/siof_types.h diff --git a/infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp b/infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp new file mode 100644 index 000000000..535bb947e --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#include + +void FN_out_of_bound_Bad(std::vector v) { + unsigned int n = v.size(); + v[n] = 1; +}