fix compilation on later glibc/gcc versions with stricter checks
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index 06ba34d..a58e392 100644 (file)
--- a/file.c
+++ b/file.c
@@ -454,7 +454,8 @@ void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool
        }
 
        rewind(f);
-       ftruncate(fileno(f), 0);
+       if (ftruncate(fileno(f), 0) < 0)
+               UCI_THROW(ctx, UCI_ERR_IO);
 
        uci_export(ctx, f, p, false);
        UCI_TRAP_RESTORE(ctx);
@@ -528,6 +529,7 @@ static char **uci_list_config_files(struct uci_context *ctx)
                buf += strlen(buf) + 1;
        }
        free(dir);
+       globfree(&globbuf);
        return configs;
 }