Closed theHamsta closed 2 years ago
Clang returns a warning about returning a pointer to a stack variable
CXX(target) Release/obj.target/tree_sitter_hack_binding/bindings/node/binding.o CXX(target) Release/obj.target/tree_sitter_hack_binding/src/scanner.o ../src/scanner.cc:106:14: warning: address of stack memory associated with local variable 'str' returned [-Wreturn-stack-address] return str.c_str(); ^~~ 1 warning generated.
The affected function return a pointer to a local string that is destroying at the end of function scope. This is a use-after-free bug.
x
[ ]
Steps to reproduce the behavior:
N/A not a runtime bug.
tree-sitter-hack version: dd7c1bb8b11d290db4aec173740efdb510f0bba9
Run tree-sitter generate with CC=clang-14
tree-sitter generate
CC=clang-14
OS version(s): Ubuntu 21.10
N/A
Fixed in https://github.com/slackhq/tree-sitter-hack/pull/38
Describe the bug
Clang returns a warning about returning a pointer to a stack variable
The affected function return a pointer to a local string that is destroying at the end of function scope. This is a use-after-free bug.
Requirements (place an
x
in each of the[ ]
)**To Reproduce
Steps to reproduce the behavior:
Expected behavior
N/A not a runtime bug.
Screenshots
Reproducible in:
tree-sitter-hack version: dd7c1bb8b11d290db4aec173740efdb510f0bba9
Run
tree-sitter generate
withCC=clang-14
OS version(s): Ubuntu 21.10
Additional context
N/A