Skip to content

Commit deba342

Browse files
committed
debug: ensure valgrind will work when calling YARP.dump
1 parent e7beec6 commit deba342

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ext/yarp/extension.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,21 @@ dump(int argc, VALUE *argv, VALUE self) {
8383

8484
yp_string_t input;
8585
input_load_string(&input, string);
86-
return dump_input(&input, check_string(filepath));
86+
87+
#ifdef YARP_DEBUG_MODE_BUILD
88+
size_t length = yp_string_length(&input);
89+
char* dup = malloc(length);
90+
memcpy(dup, yp_string_source(&input), length);
91+
yp_string_constant_init(&input, dup, length);
92+
#endif
93+
94+
VALUE value = dump_input(&input, check_string(filepath));
95+
96+
#ifdef YARP_DEBUG_MODE_BUILD
97+
free(dup);
98+
#endif
99+
100+
return value;
87101
}
88102

89103
// Dump the AST corresponding to the given file to a string.

0 commit comments

Comments
 (0)