You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
815 B
46 lines
815 B
/*
|
|
* 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 <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
void exit_good() {
|
|
int arr[1];
|
|
exit(1);
|
|
// unreachable
|
|
arr[42] = 42;
|
|
}
|
|
|
|
void fgetc_m1_bad(FILE* f) {
|
|
int arr[10000];
|
|
int c = fgetc(f);
|
|
arr[c] = 42;
|
|
}
|
|
|
|
void fgetc_255_bad(FILE* f) {
|
|
int arr[255];
|
|
int c = fgetc(f);
|
|
if (c >= 0) {
|
|
arr[c] = 42;
|
|
}
|
|
}
|
|
|
|
void fgetc_256_good(FILE* f) {
|
|
int arr[256];
|
|
int c = fgetc(f);
|
|
if (c >= 0) {
|
|
arr[c] = 42;
|
|
}
|
|
}
|
|
|
|
void fgetc_257_good(FILE* f) {
|
|
int arr[257];
|
|
int c = fgetc(f);
|
|
arr[c + 1] = 42;
|
|
}
|