From: Howard Chu Date: Tue, 9 May 2006 11:09:04 +0000 (+0000) Subject: check for NULLs from ber_mem funcs X-Git-Tag: OPENLDAP_REL_ENG_2_4_1ALPHA~2^2~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ab7e975159c7b12278eed14b763f54e5251721c7;p=openldap check for NULLs from ber_mem funcs --- diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index e630621b88..bda1982bcd 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -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 ),