blob: allow values to be added to blobmsg using multiple different types, but suppres...
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index 509ed73..36bfdda 100644 (file)
--- a/file.c
+++ b/file.c
@@ -702,9 +702,13 @@ 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);
 
-       mktemp(filename);
-       if (!*filename)
+       if (!mktemp(filename))
+               *filename = 0;
+
+       if (!*filename) {
+               free(filename);
                UCI_THROW(ctx, UCI_ERR_IO);
+       }
 
        if ((stat(filename, &statbuf) == 0) && ((statbuf.st_mode & S_IFMT) != S_IFREG))
                UCI_THROW(ctx, UCI_ERR_IO);