Reviewed By: sblackshear Differential Revision: D6231607 fbshipit-source-id: ac14179master
parent
acd68a00d1
commit
979c476fa3
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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 <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
int define_array_ok() {
|
||||||
|
size_t len = 10;
|
||||||
|
uint8_t a[len]; // we should not report on array definition
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bad1() {
|
||||||
|
int a[10];
|
||||||
|
|
||||||
|
return a[2]; // report here as values of the array are not initialized
|
||||||
|
}
|
||||||
|
|
||||||
|
void use_int(int);
|
||||||
|
|
||||||
|
int bad2() {
|
||||||
|
int a[10];
|
||||||
|
use_int(a[2]); // report here as values of the array are not initialized
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int use_array_ok() {
|
||||||
|
int a[10];
|
||||||
|
a[1] = 5;
|
||||||
|
|
||||||
|
return a[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
int initialize_array_ok1() {
|
||||||
|
int arr[10];
|
||||||
|
arr[0] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
int initialize_array_ok2() {
|
||||||
|
int arr[] = {1, 2};
|
||||||
|
arr[0] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void use_array(int[]);
|
||||||
|
|
||||||
|
int pass_array_FN() {
|
||||||
|
int arr[5];
|
||||||
|
use_array(arr); // we do not report here because of intraprocedural analysi a
|
||||||
|
// the array passed by ref
|
||||||
|
}
|
||||||
|
|
||||||
|
int array_length_undef_bad() {
|
||||||
|
int x;
|
||||||
|
int arr[x];
|
||||||
|
}
|
@ -1 +1,4 @@
|
|||||||
|
codetoanalyze/objc/uninit/arrays.m, array_length_undef_bad, 2, UNINITIALIZED_VALUE, []
|
||||||
|
codetoanalyze/objc/uninit/arrays.m, bad1, 3, UNINITIALIZED_VALUE, []
|
||||||
|
codetoanalyze/objc/uninit/arrays.m, bad2, 2, UNINITIALIZED_VALUE, []
|
||||||
codetoanalyze/objc/uninit/uninit_blocks.m, A_bad1, 5, UNINITIALIZED_VALUE, []
|
codetoanalyze/objc/uninit/uninit_blocks.m, A_bad1, 5, UNINITIALIZED_VALUE, []
|
||||||
|
Loading…
Reference in new issue