On Fri, Jun 12, 2015 at 5:47 AM, solar <[email protected]> wrote:
>
> [...]
>   char* retval = (char*)ToCString(String::Utf8Value(result));
>   printf("retval = %s, %p \n", retval, retval);
>
>
That's a classical use-after-free bug: String::Utf8Value(result) results in
a temporary object which is dead after the first line, see
http://en.cppreference.com/w/cpp/language/lifetime#Temporary_object_lifetime.
String::Utf8Value's destructor frees the underlying buffer, so retval
always points to dead memory. Depending on your compiler/runtime/etc.
anything can happen when you use that. Hint: Use e.g. valgrind/ASAN/... or
other memory debuggers to easily find such bugs.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to