summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-08-12 17:30:01 +0000
committerSimo Sorce <idra@samba.org>2001-08-12 17:30:01 +0000
commit2e783a47076bd0994b6ce86df7ec967bc1c2da63 (patch)
treec6504d6e8396eef290fe499abb8586b758f1f3d4 /source3/passdb
parentddec8306586414cc02eca612777bb547cb8dbcae (diff)
downloadsamba-2e783a47076bd0994b6ce86df7ec967bc1c2da63.tar.gz
samba-2e783a47076bd0994b6ce86df7ec967bc1c2da63.tar.bz2
samba-2e783a47076bd0994b6ce86df7ec967bc1c2da63.zip
this is a big global fix for the ptr = Realloc(ptr, size) bug.
many possible mem leaks, and segfaults fixed. someone should port this fix to 2.2 also. (This used to be commit fa8e55b8b465114ce209344965c1ca0333b84db9)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/ldap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c
index 9987990cc2..ee99664af4 100644
--- a/source3/passdb/ldap.c
+++ b/source3/passdb/ldap.c
@@ -378,7 +378,7 @@ static void ldap_get_sam_passwd(LDAP *ldap_struct, LDAPMessage *entry,
************************************************************************/
static void make_a_mod(LDAPMod ***modlist,int modop, char *attribute, char *value)
{
- LDAPMod **mods;
+ LDAPMod **mods, **tmods;
int i;
int j;
@@ -386,12 +386,13 @@ static void make_a_mod(LDAPMod ***modlist,int modop, char *attribute, char *valu
if (mods == NULL)
{
- mods = (LDAPMod **)malloc( sizeof(LDAPMod *) );
- if (mods == NULL)
+ tmods = (LDAPMod **)malloc( sizeof(LDAPMod *) );
+ if (tmods == NULL)
{
DEBUG(0,("make_a_mod: out of memory!\n"));
return;
}
+ mods = tmods;
mods[0] = NULL;
}
@@ -406,12 +407,13 @@ static void make_a_mod(LDAPMod ***modlist,int modop, char *attribute, char *valu
if (mods[i] == NULL)
{
- mods = (LDAPMod **)Realloc( mods, (i+2) * sizeof( LDAPMod * ) );
- if (mods == NULL)
+ tmods = (LDAPMod **)Realloc( mods, (i+2) * sizeof( LDAPMod * ) );
+ if (tmods == NULL)
{
DEBUG(0,("make_a_mod: out of memory!\n"));
return;
}
+ mods = tmods;
mods[i] = (LDAPMod *)malloc( sizeof( LDAPMod ) );
if (mods[i] == NULL)
{
@@ -426,18 +428,21 @@ static void make_a_mod(LDAPMod ***modlist,int modop, char *attribute, char *valu
if (value ! = NULL )
{
+ char **tmval;
+
j = 0;
if ( mods[ i ]->mod_values ! = NULL )
{
for ( ; mods[ i ]->mod_values[ j ] ! = NULL; j++ );
}
- mods[ i ]->mod_values = (char **)Realloc(mods[ i ]->mod_values,
+ tmval = (char **)Realloc(mods[ i ]->mod_values,
(j+2) * sizeof( char * ));
- if ( mods[ i ]->mod_values == NULL)
+ if ( tmval == NULL)
{
DEBUG(0, "make_a_mod: Memory allocation failure!\n");
return;
}
+ mods[ i ]->mod_values = tmval;
mods[ i ]->mod_values[ j ] = strdup(value);
mods[ i ]->mod_values[ j + 1 ] = NULL;
}