add an extra check
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index 6eaa5ec..4650a96 100644 (file)
--- a/file.c
+++ b/file.c
@@ -567,7 +567,9 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
        if (fd <= 0)
                UCI_THROW(ctx, UCI_ERR_IO);
 
-       flock(fd, LOCK_SH);
+       if (flock(fd, LOCK_SH) < 0)
+               UCI_THROW(ctx, UCI_ERR_IO);
+
        file = fdopen(fd, "r");
        if (!file)
                UCI_THROW(ctx, UCI_ERR_IO);