...

Source file src/cmd/cgo/internal/testsanitizers/testdata/asan_global2_fail.go

Documentation: cmd/cgo/internal/testsanitizers/testdata

     1  // Copyright 2022 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  struct ss {
    12  	int *p;
    13  	int len;
    14  	int cap;
    15  };
    16  
    17  int test(struct ss *a) {
    18  	struct ss *t = a + 1;
    19  	t->len = 100;          // BOOM
    20  	return t->len;
    21  }
    22  */
    23  import "C"
    24  import "fmt"
    25  
    26  var tt C.struct_ss
    27  
    28  func main() {
    29  	r := C.test(&tt)
    30  	fmt.Println("r value = ", r)
    31  }
    32  

View as plain text