From: Ken Hornstein Date: Fri, 15 Mar 2013 23:42:43 +0000 (-0400) Subject: Turns out the close function can be called with FILE * == NULL, so handle X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/f5d307951949b2787173fd2dc0aa413b59a9486e?ds=inline;hp=--cc Turns out the close function can be called with FILE * == NULL, so handle that case. --- f5d307951949b2787173fd2dc0aa413b59a9486e diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 8506faf8..987b922c 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -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);