Open maxnordlund opened 10 years ago
Yes, it's a use after free. Nice catch.
Since pointerVal is only called by Object.Set, and I think the memory handling for other types is incorrect as well, I think that whole function body should be moved into Object.Set.
The other memory problem here is that while returning an unsafe.Pointer does cause the pointed to Go value to escape to heap, the value is never freed if it is passed to a C function as a void * and is not type converted back to a Go pointer. So while the other types don't cause undefined behavior like strings do here, they are still memory leaks.
I was browsing through the code today and noticed something that looked odd:
Won't this create a unsafe memory access?