]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/vlvctrl.c
ITS#6684
[openldap] / libraries / libldap / vlvctrl.c
index cd3efba1398a8b866937c3c3079914ab14c3bcc0..1ecf5f4bee87b309a1e721ab9c9e11def4b669b9 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -101,6 +101,7 @@ ldap_create_vlv_control_value(
 
        value->bv_val = NULL;
        value->bv_len = 0;
+       ld->ld_errno = LDAP_SUCCESS;
 
        ber = ldap_alloc_ber_with_options( ld );
        if ( ber == NULL ) {
@@ -210,7 +211,6 @@ ldap_create_vlv_control(
        LDAPControl **ctrlp )
 {
        struct berval   value;
-       BerElement      *ber;
 
        if ( ctrlp == NULL ) {
                ld->ld_errno = LDAP_PARAM_ERROR;
@@ -219,19 +219,12 @@ ldap_create_vlv_control(
 
        ld->ld_errno = ldap_create_vlv_control_value( ld, vlvinfop, &value );
        if ( ld->ld_errno == LDAP_SUCCESS ) {
-               if ((ber = ldap_alloc_ber_with_options(ld)) == NULL) {
-                       ld->ld_errno = LDAP_NO_MEMORY;
-                       return LDAP_NO_MEMORY;
-               }
 
-               ld->ld_errno = ldap_create_control( LDAP_CONTROL_VLVREQUEST,
-                       ber, 1, ctrlp );
-               if ( ld->ld_errno == LDAP_SUCCESS ) {
-                       (*ctrlp)->ldctl_value = value;
-               } else {
+               ld->ld_errno = ldap_control_create( LDAP_CONTROL_VLVREQUEST,
+                       1, &value, 0, ctrlp );
+               if ( ld->ld_errno != LDAP_SUCCESS ) {
                        LDAP_FREE( value.bv_val );
                }
-               ber_free(ber, 1);
        }
 
        return ld->ld_errno;