]> diplodocus.org Git - nmh/commitdiff
Turns out the close function can be called with FILE * == NULL, so handle
authorKen Hornstein <kenh@pobox.com>
Fri, 15 Mar 2013 23:42:43 +0000 (19:42 -0400)
committerKen Hornstein <kenh@pobox.com>
Fri, 15 Mar 2013 23:42:43 +0000 (19:42 -0400)
that case.

sbr/lock_file.c

index 8506faf818c4a05251cf9db72f44eb583abadcb9..987b922ced9076b12879a6a65dd56db825b03909 100644 (file)
@@ -229,8 +229,13 @@ lkclosedata(int fd, const char *name)
 int
 lkfclosedata(FILE *f, const char *name)
 {
-    int fd = fileno(f);
-    int rc = fclose(f);
+    int fd, rc;
+
+    if (f == NULL)
+       return 0;
+    
+    fd = fileno(f);
+    rc = fclose(f);
 
     if (datalocktype == DOT_LOCKING)
        lkclose_dot(fd, name);
@@ -252,8 +257,13 @@ lkclosespool(int fd, const char *name)
 int
 lkfclosespool(FILE *f, const char *name)
 {
-    int fd = fileno(f);
-    int rc = fclose(f);
+    int fd, rc;
+
+    if (f == NULL)
+       return 0;
+    
+    fd = fileno(f);
+    rc = fclose(f);
 
     if (spoollocktype == DOT_LOCKING)
        lkclose_dot(fd, name);