]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passfile.c
ITS#6929 fclose(password file) on failure.
[openldap] / libraries / liblutil / passfile.c
index 605224d66cc971af4870068b48b635b03d014f4f..52225146e2873c93151615a92ec8735001495a1c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2010 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ lutil_get_filed_password(
        passwd->bv_val = (char *) ber_memalloc( passwd->bv_len + 1 );
        if( passwd->bv_val == NULL ) {
                perror( filename );
+               fclose( f );
                return -1;
        }
 
@@ -79,6 +80,7 @@ lutil_get_filed_password(
                                ber_memfree( passwd->bv_val );
                                passwd->bv_val = NULL;
                                passwd->bv_len = 0;
+                               fclose( f );
                                return -1;
                        }
                        nleft = passwd->bv_len;
@@ -92,6 +94,7 @@ lutil_get_filed_password(
                        ber_memfree( passwd->bv_val );
                        passwd->bv_val = NULL;
                        passwd->bv_len = 0;
+                       fclose( f );
                        return -1;
                }