Call fileno and krb5_lock_file before calling fclose, rather than after.
authorKen Raeburn <raeburn@mit.edu>
Sat, 14 Oct 2006 00:17:48 +0000 (00:17 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 14 Oct 2006 00:17:48 +0000 (00:17 +0000)
Caught by valgrind.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18700 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/dbutil/dump.c

index 12b6a46efe26f267d13138893acac14edbed54fe..e1f1d8848fdfad26faf5a7a6d7ea8254590eb101 100644 (file)
@@ -1190,8 +1190,12 @@ dump_db(argc, argv)
             exit_status++;
        }
        if (ofile && f != stdout && !exit_status) {
-            fclose(f);
-            update_ok_file(ofile);
+           if (locked) {
+               (void) krb5_lock_file(util_context, fileno(f), KRB5_LOCKMODE_UNLOCK);
+               locked = 0;
+           }
+           fclose(f);
+           update_ok_file(ofile);
        }
     }
     if (locked)