]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/sql-wrap.c
re-fix previus commit the other way 'round (rids are < 1000)
[openldap] / servers / slapd / back-sql / sql-wrap.c
index 7176d0dc4bafba44bd2627cc68e9ca8733e4dd6a..d01d9cbb31e1e403927f9b8e2ed76fd6e131b934 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2005 The OpenLDAP Foundation.
+ * Copyright 1999-2007 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * Portions Copyright 2004 Mark Adamson.
@@ -162,12 +162,26 @@ backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx )
 
                row->col_names = (BerVarray)ber_memcalloc_x( row->ncols + 1, 
                                sizeof( struct berval ), ctx );
+               if ( !row->col_names ) goto nomem3;
                row->cols = (char **)ber_memcalloc_x( row->ncols + 1, 
                                sizeof( char * ), ctx );
+               if ( !row->cols ) goto nomem2;
                row->col_prec = (UDWORD *)ber_memcalloc_x( row->ncols,
                                sizeof( UDWORD ), ctx );
+               if ( !row->col_prec ) goto nomem1;
                row->value_len = (SQLINTEGER *)ber_memcalloc_x( row->ncols,
                                sizeof( SQLINTEGER ), ctx );
+               if ( !row->value_len ) {
+                       ber_memfree_x( row->col_prec, ctx );
+                       row->col_prec = NULL;
+nomem1:                ber_memfree_x( row->cols, ctx );
+                       row->cols = NULL;
+nomem2:                ber_memfree_x( row->col_names, ctx );
+                       row->col_names = NULL;
+nomem3:                Debug( LDAP_DEBUG_ANY, "backsql_BindRowAsStrings: "
+                               "out of memory\n", 0, 0, 0 );
+                       return LDAP_NO_MEMORY;
+               }
                for ( i = 1; i <= row->ncols; i++ ) {
                        rc = SQLDescribeCol( sth, (SQLSMALLINT)i, &colname[ 0 ],
                                        (SQLUINTEGER)( sizeof( colname ) - 1 ),