summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDmitry V. Levin <[email protected]>2021-09-06 10:00:00 +0000
committerDmitry V. Levin <[email protected]>2021-09-09 08:03:00 +0000
commitc1a67b39611f3e396121cf5333b0e77b537e9741 (patch)
tree1ac3dcfd8b06daa0f1c93732b960af1813ca35db /lib
parent5df759af555e6ffc385ead7683bcbd059a698944 (diff)
Use xasprintf instead of asprintf followed by error(EXIT_FAILURE)
Signed-off-by: Dmitry V. Levin <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog3
-rw-r--r--lib/color.c6
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 468001f8..96eaa330 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,8 @@
2021-09-06 Dmitry V. Levin <[email protected]>
+ * color.c (parse_opt): Replace asprintf followed by error(EXIT_FAILURE)
+ with xasprintf.
+
* xasprintf.c: New file.
* Makefile.am (libeu_a_SOURCES): Add it.
* libeu.h (xasprintf): New prototype.
diff --git a/lib/color.c b/lib/color.c
index 454cb7ca..e43b6143 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -188,10 +188,8 @@ valid arguments are:\n\
if (name_len == known[i].len
&& memcmp (start, known[i].name, name_len) == 0)
{
- if (asprintf (known[i].varp, "\e[%.*sm",
- (int) (env - val), val) < 0)
- error (EXIT_FAILURE, errno,
- _("cannot allocate memory"));
+ *known[i].varp =
+ xasprintf ("\e[%.*sm", (int) (env - val), val);
break;
}
}