From 8fd23795f80edd2175b93ab3f05633b877c9c3b1 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 5 May 2003 10:23:33 +0000 Subject: [PATCH] Don't crash slapi_filter_get_subfilt() if no "any" filter --- servers/slapd/slapi/slapi_utils.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 8bb1a8660a..6cd270f828 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1710,13 +1710,17 @@ slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, */ *type = f->f_sub_desc->ad_cname.bv_val; *initial = f->f_sub_initial.bv_val ? slapi_ch_strdup(f->f_sub_initial.bv_val) : NULL; - for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) - ; - *any = (char **)slapi_ch_malloc( (i + 1) * sizeof(char *) ); - for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { - (*any)[i] = slapi_ch_strdup(f->f_sub_any[i].bv_val); + if ( f->f_sub_any != NULL ) { + for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) + ; + *any = (char **)slapi_ch_malloc( (i + 1) * sizeof(char *) ); + for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { + (*any)[i] = slapi_ch_strdup(f->f_sub_any[i].bv_val); + } + (*any)[i] = NULL; + } else { + *any = NULL; } - (*any)[i] = NULL; *final = f->f_sub_final.bv_val ? slapi_ch_strdup(f->f_sub_final.bv_val) : NULL; return 0; -- 2.39.5