1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

move to SAFE_FREE()

This commit is contained in:
Simo Sorce 0001-01-01 00:00:00 +00:00
parent 29db6ef7a7
commit 89833bbbd8
5 changed files with 15 additions and 22 deletions

View File

@ -147,8 +147,7 @@ BOOL add_domain_alias(LOCAL_GRP **alss, int *num_alss, LOCAL_GRP *als)
talss = Realloc((*alss), ((*num_alss)+1) * sizeof(LOCAL_GRP));
if (talss == NULL) {
if (*alss)
free(*alss);
SAFE_FREE(*alss);
return False;
} else
(*alss) = talss;
@ -228,8 +227,7 @@ BOOL iterate_getuseraliasnam(char *user_name, LOCAL_GRP **alss, int *num_alss)
ret = add_domain_alias(alss, num_alss, als);
}
free(mem);
mem = NULL;
SAFE_FREE(mem);
num_mem = 0;
if (!ret)

View File

@ -137,8 +137,7 @@ static char *get_alias_members(char *p, int *num_mem, LOCAL_GRP_MEMBER **members
continue;
}
if (mbrs == NULL) {
if (*members)
free(*members);
SAFE_FREE(*members);
return NULL;
} else
(*members) = mbrs;

View File

@ -145,8 +145,7 @@ BOOL add_domain_group(DOMAIN_GRP **grps, int *num_grps, DOMAIN_GRP *grp)
tgrps = Realloc((*grps), ((*num_grps)+1) * sizeof(DOMAIN_GRP));
if (tgrps == NULL) {
if (*grps)
free(*grps);
SAFE_FREE(*grps);
return False;
} else
(*grps) = tgrps;
@ -224,8 +223,7 @@ BOOL iterate_getusergroupsnam(char *user_name, DOMAIN_GRP **grps, int *num_grps)
ret = add_domain_group(grps, num_grps, grp);
}
free(mem);
mem = NULL;
SAFE_FREE(mem);
num_mem = 0;
if (!ret)

View File

@ -132,8 +132,7 @@ static char *get_group_members(char *p, int *num_mem, DOMAIN_GRP_MEMBER **member
mbrs = Realloc((*members), ((*num_mem)+1) * sizeof(DOMAIN_GRP_MEMBER));
if (mbrs == NULL) {
if (*members)
free(*members);
SAFE_FREE(*members);
return NULL;
}
else (*members) = mbrs;

View File

@ -269,7 +269,7 @@ BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "ddffd",
&map->gid, &map->sid_name_use, &map->nt_name, &map->comment, &map->privilege);
safe_free(dbuf.dptr);
SAFE_FREE(dbuf.dptr);
if (ret != dbuf.dsize) {
DEBUG(0,("get_group_map_from_sid: mapping TDB corrupted ?\n"));
return False;
@ -294,7 +294,7 @@ BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map)
for (kbuf = tdb_firstkey(tdb);
kbuf.dptr;
newkey = tdb_nextkey(tdb, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
newkey = tdb_nextkey(tdb, kbuf), SAFE_FREE(kbuf.dptr), kbuf=newkey) {
if (strncmp(kbuf.dptr, GROUP_PREFIX, strlen(GROUP_PREFIX)) != 0) continue;
@ -308,7 +308,7 @@ BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map)
ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "ddffd",
&map->gid, &map->sid_name_use, &map->nt_name, &map->comment, &map->privilege);
safe_free(dbuf.dptr);
SAFE_FREE(dbuf.dptr);
if (ret != dbuf.dsize) continue;
if (gid==map->gid)
@ -331,7 +331,7 @@ BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map)
for (kbuf = tdb_firstkey(tdb);
kbuf.dptr;
newkey = tdb_nextkey(tdb, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
newkey = tdb_nextkey(tdb, kbuf), SAFE_FREE(kbuf.dptr), kbuf=newkey) {
if (strncmp(kbuf.dptr, GROUP_PREFIX, strlen(GROUP_PREFIX)) != 0) continue;
@ -345,7 +345,7 @@ BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map)
ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "ddffd",
&map->gid, &map->sid_name_use, &map->nt_name, &map->comment, &map->privilege);
safe_free(dbuf.dptr);
SAFE_FREE(dbuf.dptr);
if (ret != dbuf.dsize) continue;
if (StrCaseCmp(name, map->nt_name)==0)
@ -376,7 +376,7 @@ BOOL group_map_remove(DOM_SID sid)
dbuf = tdb_fetch(tdb, kbuf);
if (!dbuf.dptr) return False;
safe_free(dbuf.dptr);
SAFE_FREE(dbuf.dptr);
if(tdb_delete(tdb, kbuf) != TDB_SUCCESS)
return False;
@ -404,7 +404,7 @@ BOOL enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap,
for (kbuf = tdb_firstkey(tdb);
kbuf.dptr;
newkey = tdb_nextkey(tdb, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
newkey = tdb_nextkey(tdb, kbuf), SAFE_FREE(kbuf.dptr), kbuf=newkey) {
if (strncmp(kbuf.dptr, GROUP_PREFIX, strlen(GROUP_PREFIX)) != 0)
continue;
@ -418,7 +418,7 @@ BOOL enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap,
ret = tdb_unpack(dbuf.dptr, dbuf.dsize, "ddffd",
&map.gid, &map.sid_name_use, &map.nt_name, &map.comment, &map.privilege);
safe_free(dbuf.dptr);
SAFE_FREE(dbuf.dptr);
if (ret != dbuf.dsize)
continue;
@ -436,8 +436,7 @@ BOOL enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap,
mapt=(GROUP_MAP *)Realloc((*rmap), (entries+1)*sizeof(GROUP_MAP));
if (!mapt) {
DEBUG(0,("enum_group_mapping: Unable to enlarge group map!\n"));
if (*rmap) free(*rmap);
*rmap=NULL;
SAFE_FREE(*rmap);
return False;
}
else (*rmap) = mapt;