diff --git a/src/jemalloc.c b/src/jemalloc.c index df0c1ebc..ccb20c81 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -865,6 +865,14 @@ malloc_conf_multi_sizes_next(const char **slab_size_segment_cur, return false; } +static void +malloc_conf_format_error(const char *msg, const char *begin, const char *end) { + size_t len = end - begin + 1; + len = len > BUFERROR_BUF ? BUFERROR_BUF : len; + + malloc_printf(": %s -- %.*s\n", msg, (int)len, begin); +} + static bool malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p, char const **v_p, size_t *vlen_p) { @@ -898,13 +906,15 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p, break; case '\0': if (opts != *opts_p) { - malloc_write(": Conf string ends " - "with key\n"); + malloc_conf_format_error( + "Conf string ends with key", + *opts_p, opts - 1); had_conf_error = true; } return true; default: - malloc_write(": Malformed conf string\n"); + malloc_conf_format_error( + "Malformed conf string", *opts_p, opts); had_conf_error = true; return true; } @@ -922,8 +932,9 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p, * comma if one exists. */ if (*opts == '\0') { - malloc_write(": Conf string ends " - "with comma\n"); + malloc_conf_format_error( + "Conf string ends with comma", + *opts_p, opts - 1); had_conf_error = true; } *vlen_p = (uintptr_t)opts - 1 - (uintptr_t)*v_p;