Closed
Description
Note that these are just a code review thing. I haven't verified it, but it looks like bugs.
-
As far as I know when you convert a C string to Go string via cgo's C.GoString, the latter doesn't free C string memory. As a result RunScript usage here leaks memory, it might allocate some strings for error structure which are then not freed in getError when being converted to Go strings:
Lines 58 to 59 in 00d2f88
-
Another memory leak here:
Line 16 in 00d2f88
ValueToString just does a malloc at the end. -
What you do in CopyString and similar places is potentially unsafe. The
sprintf
usage is unsafe:
Lines 34 to 38 in 00d2f88
IIRC std::string's length returns the length of the string without terminating null byte. And IIRC sprintf writes terminating null byte at the end to the buffer. Since you allocate memory that is 1 byte short of what is written, it's a potential out of bounds write.
Metadata
Assignees
Labels
No labels