1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 
21 #define ARRAY_LENGTH 10
22 
23 int flag;
24 
clobber(int * array,int size)25 void clobber(int *array, int size) {
26     /* Make sure it clobbers something. */
27     array[-1] = 0x123;
28     array[size] = 0x123;
29 }
30 
main(void)31 int main(void) {
32     int values[ARRAY_LENGTH];
33     int *p = (int *) malloc(sizeof(int));
34     *p = 10;
35 
36     while (!flag) {
37         sleep(1);
38     }
39 
40     /* Set a breakpint here: "b main.c:41" */
41     clobber(values, ARRAY_LENGTH);
42     printf("*p = %d\n", *p);
43     free(p);
44 
45     return 0;
46 }
47