/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
assert( result != NULL );
op->lo_depth++;
- assert( op->lo_depth > 0 );
Debug( LDAP_DEBUG_TRACE, "==> rewrite_context_apply"
" [depth=%d] string='%s'\n",
op->lo_depth, string, 0 );
+ assert( op->lo_depth > 0 );
s = (char *)string;
if ( do_continue ) {
if ( rule->lr_next == NULL ) {
- res = ( s == string ? strdup( s ) : s );
+ res = s;
}
goto rc_continue;
}
if ( res != NULL ) {
struct rewrite_action *action;
- if (s != string ) {
+ if ( s != string && s != res ) {
free( s );
}
s = res;
* result back to the string
*/
} else if ( rule->lr_next == NULL ) {
- res = ( s == string ? strdup( s ) : s );
+ res = s;
}
break;
{
struct rewrite_context *context = (struct rewrite_context *)tmp;
- assert( tmp );
+ assert( tmp != NULL );
rewrite_context_destroy( &context );
}
struct rewrite_context *context;
struct rewrite_rule *r;
- assert( pcontext );
- assert( *pcontext );
+ assert( pcontext != NULL );
+ assert( *pcontext != NULL );
context = *pcontext;
- assert( context->lc_rule );
+ assert( context->lc_rule != NULL );
for ( r = context->lc_rule->lr_next; r; ) {
struct rewrite_rule *cr = r;
free( context->lc_rule );
context->lc_rule = NULL;
- assert( context->lc_name );
+ assert( context->lc_name != NULL );
free( context->lc_name );
context->lc_name = NULL;