]> git.sur5r.net Git - openldap/commitdiff
Fix one time memory leak
authorQuanah Gibson-Mount <quanah@openldap.org>
Wed, 2 Feb 2011 23:28:27 +0000 (23:28 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 2 Feb 2011 23:28:27 +0000 (23:28 +0000)
clients/tools/ldapwhoami.c

index b8d8f3718be01ad3f6b85e215f58408afb918cb4..e6c2a237ebc7a7658ce548e5ef3901f8cd11427e 100644 (file)
@@ -113,7 +113,7 @@ main( int argc, char *argv[] )
        char            *matcheddn = NULL, *text = NULL, **refs = NULL;
        struct berval   *authzid = NULL;
        int             id, code = 0;
-       LDAPMessage     *res;
+       LDAPMessage     *res = NULL;
        LDAPControl     **ctrls = NULL;
 
        tool_init( TOOL_WHOAMI );
@@ -182,7 +182,6 @@ main( int argc, char *argv[] )
        }
 
        rc = ldap_parse_whoami( ld, res, &authzid );
-       ldap_msgfree(res);
 
        if( rc != LDAP_SUCCESS ) {
                tool_perror( "ldap_parse_whoami", rc, NULL, NULL, NULL, NULL );
@@ -199,6 +198,7 @@ main( int argc, char *argv[] )
        }
 
 skip:
+       ldap_msgfree(res);
        if ( verbose || ( code != LDAP_SUCCESS ) ||
                matcheddn || text || refs || ctrls )
        {