]> git.sur5r.net Git - openldap/commitdiff
check for NULLs from ber_mem funcs
authorHoward Chu <hyc@openldap.org>
Tue, 9 May 2006 11:09:04 +0000 (11:09 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 9 May 2006 11:09:04 +0000 (11:09 +0000)
servers/slapd/back-sql/sql-wrap.c

index e630621b88bd7b401288ca0b6a00c00fca1b34a4..bda1982bcdbb47de64a5eddd6716730a45eca556 100644 (file)
@@ -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 ),