krb5_rc_io_open_internal on error will call close(-1)
authorEzra Peisach <epeisach@mit.edu>
Mon, 18 Dec 2006 11:26:59 +0000 (11:26 +0000)
committerEzra Peisach <epeisach@mit.edu>
Mon, 18 Dec 2006 11:26:59 +0000 (11:26 +0000)
If there is an error in opening the replay cache - memory is freed, but
close() is invoked with -1 (failure from open()).  While technically,
close() will return EBADF in such a case, and nothing bad will happen,
valgrind picks up on this and provides an error...

ticket: new

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

src/lib/krb5/rcache/rc_io.c

index 8453d18323584c25a89dbfbc6e077d2407ceafc9..adc6a8c49cece9e39b19fce8fefc7b17b1082842 100644 (file)
@@ -168,7 +168,9 @@ krb5_rc_io_creat(krb5_context context, krb5_rc_iostuff *d, char **fn)
            FREE(d->fn);
            d->fn = NULL;
        }
-       (void) close(d->fd);
+       if (d->fd != -1) {
+         (void) close(d->fd);
+       }
     }
     return retval;
 }