Skip to content

Commit

Permalink
Don't just exit in print_error().
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Jan 26, 2024
1 parent fb11755 commit c5e3224
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/java.base/unix/native/libmallochooks/mallochooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,8 @@ static void print_size(size_t size);

#endif

static void print_error(char const* msg, int error_code) {
static void print_error(char const* msg) {
write_safe(2, msg, strlen(msg));

if (error_code > 0) {
exit(error_code);
}
}

#if !defined(MALLOC_REPLACEMENT)
Expand Down Expand Up @@ -169,7 +165,8 @@ static malloc_func_t* malloc_for_fallback = MALLOC_REPLACEMENT;
#if !defined(FREE_REPLACEMENT)
static void fallback_free(void* ptr) {
if (((char*) ptr < fallback_buffer) && ((char*) ptr >= fallback_buffer_end)) {
print_error("fallback free called with wrong pointer!\n", 1);
print_error("fallback free called with wrong pointer!\n");
exit(1);
}
}

Expand Down Expand Up @@ -218,7 +215,8 @@ static calloc_func_t* calloc_for_fallback = CALLOC_REPLACEMENT;
#if !defined(REALLOC_REPLACEMENT)
static void* fallback_realloc(void* ptr, size_t size) {
if (((char*) ptr < fallback_buffer) && ((char*) ptr >= fallback_buffer_end)) {
print_error("fallback realloc called with wrong pointer!\n", 1);
print_error("fallback realloc called with wrong pointer!\n");
exit(1);
}

void* result = fallback_malloc(size);
Expand Down Expand Up @@ -420,8 +418,9 @@ static void assign_function(void** dest, char const* symbol) {
*dest = dlsym(RTLD_NEXT, symbol);

if (*dest == NULL) {
print_error(symbol, 0);
print_error(" not found!\n", 1);
print_error(symbol);
print_error(" not found!\n");
exit(1);
}

print("Found at ");
Expand Down

0 comments on commit c5e3224

Please sign in to comment.