]> Cypherpunks.ru repositories - gostls13.git/blob - misc/cgo/testsanitizers/testdata/asan4_fail.go
12098458ae91d27f6c9d06c316240136dd8c3edf
[gostls13.git] / misc / cgo / testsanitizers / testdata / asan4_fail.go
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 /*
8 #include <stdlib.h>
9 #include <stdio.h>
10
11 void test(int* a) {
12         // Access Go pointer out of bounds.
13         a[3] = 300;          // BOOM
14         // We shouldn't get here; asan should stop us first.
15         printf("a[3]=%d\n", a[3]);
16 }*/
17 import "C"
18
19 func main() {
20         var cIntArray [2]C.int
21         C.test(&cIntArray[0]) // cIntArray is moved to heap.
22 }