summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/vote.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index 8700c2ab..01e518f1 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -31,6 +31,16 @@ convert_to_newversion(FILE *fp, char *file, char *ballots)
int count = -1, tmp, fd, fdw;
FILE *fpw;
+ assert(fp);
+ flock(fileno(fp), LOCK_EX);
+ rewind(fp);
+ fgets(buf, sizeof(buf), fp);
+ if (index(buf, ',')) {
+ rewind(fp);
+ flock(fileno(fp), LOCK_UN);
+ return;
+ }
+
if ((fd = open(ballots, O_RDONLY)) != -1) {
sprintf(buf, "%s.new", ballots);
fdw = open(buf, O_WRONLY | O_CREAT, 0600);
@@ -47,16 +57,6 @@ convert_to_newversion(FILE *fp, char *file, char *ballots)
Rename(buf, ballots);
}
-
- assert(fp);
- flock(fileno(fp), LOCK_EX);
- rewind(fp);
- fgets(buf, sizeof(buf), fp);
- if (index(buf, ',')) {
- rewind(fp);
- flock(fileno(fp), LOCK_UN);
- return;
- }
sscanf(buf, " %d", &tmp);
sprintf(buf2, "%s.new", file);
if (!(fpw = fopen(buf2, "w"))) {