From 7a5d837a94b869cdea6c99b8ddbad5af72712130 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 24 Jan 2005 13:06:58 +0000 Subject: [PATCH] (__argp_error): Check return value of __asprintf (__argp_failure): Translate error message --- lib/argp-help.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/argp-help.c b/lib/argp-help.c index c506b57b0a..7c700be45a 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -1745,7 +1745,8 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) { char *buf; - __asprintf (&buf, fmt, ap); + if (__asprintf (&buf, fmt, ap) < 0) + buf = NULL; __fwprintf (stream, L"%s: %s\n", state ? state->name : __argp_short_program_name (), @@ -1823,7 +1824,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum, { char *buf; - __asprintf (&buf, fmt, ap); + if (__asprintf (&buf, fmt, ap) < 0) + buf = NULL; __fwprintf (stream, L": %s", buf); @@ -1863,7 +1865,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum, #endif #if !_LIBC if (! s && ! (s = strerror (errnum))) - s = "Unknown system error"; /* FIXME: translate this */ + s = dgettext (state->root_argp->argp_domain, + "Unknown system error"); #endif fputs (s, stream); } -- 2.30.2