mirror of
https://github.com/cryb-to/cryb-to.git
synced 2025-01-17 17:21:16 +00:00
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.
This commit is contained in:
parent
7a2defcf42
commit
eab216c06a
1 changed files with 3 additions and 3 deletions
|
@ -50,7 +50,7 @@ struct t_file *
|
||||||
t_fopen(const char *filename)
|
t_fopen(const char *filename)
|
||||||
{
|
{
|
||||||
struct t_file *tf;
|
struct t_file *tf;
|
||||||
int fd;
|
int fd, ret;
|
||||||
|
|
||||||
if ((tf = calloc(sizeof *tf, 1)) == NULL)
|
if ((tf = calloc(sizeof *tf, 1)) == NULL)
|
||||||
err(1, "%s(): calloc()", __func__);
|
err(1, "%s(): calloc()", __func__);
|
||||||
|
@ -58,9 +58,9 @@ t_fopen(const char *filename)
|
||||||
if ((tf->name = strdup(filename)) == NULL)
|
if ((tf->name = strdup(filename)) == NULL)
|
||||||
err(1, "%s(): strdup()", __func__);
|
err(1, "%s(): strdup()", __func__);
|
||||||
} else {
|
} else {
|
||||||
asprintf(&tf->name, "%s.%lu.%p.tmp",
|
ret = asprintf(&tf->name, "%s.%lu.%p.tmp",
|
||||||
t_progname, (unsigned long)getpid(), (void *)tf);
|
t_progname, (unsigned long)getpid(), (void *)tf);
|
||||||
if (tf->name == NULL)
|
if (ret < 0 || tf->name == NULL)
|
||||||
err(1, "%s(): asprintf()", __func__);
|
err(1, "%s(): asprintf()", __func__);
|
||||||
}
|
}
|
||||||
if ((fd = open(tf->name, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)
|
if ((fd = open(tf->name, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)
|
||||||
|
|
Loading…
Reference in a new issue