]> git.sur5r.net Git - openldap/blob - servers/slapd/mods.c
Add a safety check to bvcasechr
[openldap] / servers / slapd / mods.c
1 /*
2  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5 /*
6  * Copyright (c) 1995 Regents of the University of Michigan.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms are permitted
10  * provided that this notice is preserved and that due credit is given
11  * to the University of Michigan at Ann Arbor. The name of the University
12  * may not be used to endorse or promote products derived from this
13  * software without specific prior written permission. This software
14  * is provided ``as is'' without express or implied warranty.
15  */
16
17 #include "portable.h"
18
19 #include "slap.h"
20
21 void
22 slap_mod_free(
23         Modification    *mod,
24         int                             freeit
25 )
26 {
27 #if 0
28         if ( mod->sm_type.bv_val)
29                 free( mod->sm_type.bv_val );
30 #endif
31         if ( mod->sm_bvalues != NULL )
32                 ber_bvarray_free( mod->sm_bvalues );
33
34         if( freeit )
35                 free( mod );
36 }
37
38 void
39 slap_mods_free(
40     Modifications       *ml
41 )
42 {
43         Modifications *next;
44
45         for ( ; ml != NULL; ml = next ) {
46                 next = ml->sml_next;
47
48                 slap_mod_free( &ml->sml_mod, 0 );
49                 free( ml );
50         }
51 }
52
53 void
54 slap_modlist_free(
55     LDAPModList *ml
56 )
57 {
58         LDAPModList *next;
59
60         for ( ; ml != NULL; ml = next ) {
61                 next = ml->ml_next;
62
63                 if (ml->ml_type)
64                         free( ml->ml_type );
65
66                 if ( ml->ml_bvalues != NULL )
67                         ber_bvecfree( ml->ml_bvalues );
68
69                 free( ml );
70         }
71 }