Skip to content

Commit 0212f0c

Browse files
dgryskideadprogram
authored andcommitted
compiler: limit level of pointer-to-pointer-to-... types
1 parent f5f4751 commit 0212f0c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
133133
if _, ok := typ.Elem().(*types.Pointer); ok {
134134
// For a pointer to a pointer, we just increase the pointer by 1
135135
ptr := c.getTypeCode(typ.Elem())
136+
// if the type is already *****T or higher, we can't make it.
137+
if typstr := typ.String(); strings.HasPrefix(typstr, "*****") {
138+
c.addError(token.NoPos, fmt.Sprintf("too many levels of pointers for typecode: %s", typstr))
139+
}
136140
return llvm.ConstGEP(c.ctx.Int8Type(), ptr, []llvm.Value{
137141
llvm.ConstInt(llvm.Int32Type(), 1, false),
138142
})

0 commit comments

Comments
 (0)