diff options
author | Mike Dalessio <[email protected]> | 2023-08-30 10:40:00 -0400 |
---|---|---|
committer | git <[email protected]> | 2023-08-30 18:27:47 +0000 |
commit | f652c05a59506dfe931f23db4965f7e40033de5e (patch) | |
tree | cfb3acc911e71223cc7337532c958e18de2d4580 /yarp/extension.c | |
parent | 1edb03788d27cf214365b849778a72c8c52c158f (diff) |
[ruby/yarp] debug: ensure valgrind will work when calling YARP.dump
https://github.com/ruby/yarp/commit/deba3420d5
Diffstat (limited to 'yarp/extension.c')
-rw-r--r-- | yarp/extension.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/yarp/extension.c b/yarp/extension.c index b46a1f8226..f959dba31a 100644 --- a/yarp/extension.c +++ b/yarp/extension.c @@ -83,7 +83,21 @@ dump(int argc, VALUE *argv, VALUE self) { yp_string_t input; input_load_string(&input, string); - return dump_input(&input, check_string(filepath)); + +#ifdef YARP_DEBUG_MODE_BUILD + size_t length = yp_string_length(&input); + char* dup = malloc(length); + memcpy(dup, yp_string_source(&input), length); + yp_string_constant_init(&input, dup, length); +#endif + + VALUE value = dump_input(&input, check_string(filepath)); + +#ifdef YARP_DEBUG_MODE_BUILD + free(dup); +#endif + + return value; } // Dump the AST corresponding to the given file to a string. |