diff options
author | Damian Gryski <[email protected]> | 2023-06-09 01:21:41 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-06-09 17:30:02 +0200 |
commit | 0212f0c0088ef53f5fe210feede55ce2877b364d (patch) | |
tree | 1011505cb50f42df78d3a710505bbaae47a7df94 | |
parent | f5f4751088bd40a8680899eefeb9854c8dbf4b33 (diff) | |
download | tinygo-0212f0c0088ef53f5fe210feede55ce2877b364d.tar.gz tinygo-0212f0c0088ef53f5fe210feede55ce2877b364d.zip |
compiler: limit level of pointer-to-pointer-to-... types
-rw-r--r-- | compiler/interface.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/interface.go b/compiler/interface.go index 3fdb30bb8..da9982148 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -133,6 +133,10 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value { if _, ok := typ.Elem().(*types.Pointer); ok { // For a pointer to a pointer, we just increase the pointer by 1 ptr := c.getTypeCode(typ.Elem()) + // if the type is already *****T or higher, we can't make it. + if typstr := typ.String(); strings.HasPrefix(typstr, "*****") { + c.addError(token.NoPos, fmt.Sprintf("too many levels of pointers for typecode: %s", typstr)) + } return llvm.ConstGEP(c.ctx.Int8Type(), ptr, []llvm.Value{ llvm.ConstInt(llvm.Int32Type(), 1, false), }) |