]> git.sur5r.net Git - openldap/commitdiff
don't leak a BerElement
authorPierangelo Masarati <ando@openldap.org>
Sat, 8 Apr 2006 17:34:00 +0000 (17:34 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 8 Apr 2006 17:34:00 +0000 (17:34 +0000)
libraries/liblber/io.c

index 934d488b7de3aa362f985e22a4c1f59eed8a1f34..1c162ecebcbe6053f4ac51ac573c6a0ebaad621d 100644 (file)
@@ -202,7 +202,8 @@ int
 ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
 {
        ber_len_t       towrite;
-       ber_slen_t      rc;     
+       ber_slen_t      rc;
+       int             retcode = 0;
 
        assert( sb != NULL );
        assert( ber != NULL );
@@ -231,16 +232,18 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
 #else
                rc = ber_int_sb_write( sb, ber->ber_rwptr, towrite );
 #endif
-               if (rc<=0) {
-                       return -1;
+               if ( rc <= 0 ) {
+                       retcode = -1;
+                       goto done;
                }
                towrite -= rc;
                ber->ber_rwptr += rc;
        } 
 
+done:;
        if ( freeit ) ber_free( ber, 1 );
 
-       return( 0 );
+       return retcode;
 }
 
 BerElement *