Skip to content

Commit

Permalink
Use fprintf for error message when loading external GC
Browse files Browse the repository at this point in the history
The error message is often long, so using a small buffer could cause it
to be truncated. rb_bug also has a 256 byte message buffer, so it could
also be truncated.
  • Loading branch information
peterzhu2118 committed Apr 26, 2024
1 parent 67b79d4 commit 353cba4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1893,10 +1893,11 @@ ruby_external_gc_init()
char *gc_so_path = getenv("RUBY_GC_LIBRARY_PATH");
void *handle = NULL;
if (gc_so_path) {
char error[128];
char error[1024];
handle = dln_open(gc_so_path, error, sizeof(error));
if (!handle) {
rb_bug("ruby_external_gc_init: Shared library %s cannot be opened (%s)", gc_so_path, error);
fprintf(stderr, "%s", error);
rb_bug("ruby_external_gc_init: Shared library %s cannot be opened", gc_so_path);
}
}

Expand Down

0 comments on commit 353cba4

Please sign in to comment.