file: add missing return code check for mktemp()
authorFelix Fietkau <nbd@openwrt.org>
Thu, 24 Oct 2013 21:25:02 +0000 (23:25 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 24 Oct 2013 21:25:02 +0000 (23:25 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
file.c

diff --git a/file.c b/file.c
index 44b2e02..36bfdda 100644 (file)
--- a/file.c
+++ b/file.c
@@ -702,7 +702,9 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
        if ((asprintf(&filename, "%s/.%s.uci-XXXXXX", ctx->confdir, p->e.name) < 0) || !filename)
                UCI_THROW(ctx, UCI_ERR_MEM);
 
        if ((asprintf(&filename, "%s/.%s.uci-XXXXXX", ctx->confdir, p->e.name) < 0) || !filename)
                UCI_THROW(ctx, UCI_ERR_MEM);
 
-       mktemp(filename);
+       if (!mktemp(filename))
+               *filename = 0;
+
        if (!*filename) {
                free(filename);
                UCI_THROW(ctx, UCI_ERR_IO);
        if (!*filename) {
                free(filename);
                UCI_THROW(ctx, UCI_ERR_IO);