From f7047a5370f492dbfc7201527acc86a73355a79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 18 Sep 2016 22:18:02 +0200 Subject: [PATCH] Check the return value from asprintf(). This is actually redundant, because we already check the pointer, which is NULL if and only if asprintf() fails and returns < 0, but the version of gcc used by Travis CI insists. I have not been able to reproduce the issue on any other platform available to me. --- lib/test/cryb_t_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/test/cryb_t_file.c b/lib/test/cryb_t_file.c index b974236..8739101 100644 --- a/lib/test/cryb_t_file.c +++ b/lib/test/cryb_t_file.c @@ -50,7 +50,7 @@ struct t_file * t_fopen(const char *filename) { struct t_file *tf; - int fd; + int fd, ret; if ((tf = calloc(sizeof *tf, 1)) == NULL) err(1, "%s(): calloc()", __func__); @@ -58,9 +58,9 @@ t_fopen(const char *filename) if ((tf->name = strdup(filename)) == NULL) err(1, "%s(): strdup()", __func__); } else { - asprintf(&tf->name, "%s.%lu.%p.tmp", + ret = asprintf(&tf->name, "%s.%lu.%p.tmp", t_progname, (unsigned long)getpid(), (void *)tf); - if (tf->name == NULL) + if (ret < 0 || tf->name == NULL) err(1, "%s(): asprintf()", __func__); } if ((fd = open(tf->name, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)