if((namerec = find_name_on_subnet( subrec, &nmbname, FIND_SELF_NAME))!=NULL)
{
struct userdata_struct *userdata;
+ int size = sizeof(struct userdata_struct) + sizeof(BOOL);
- if((userdata = (struct userdata_struct *)malloc(
- sizeof(struct userdata_struct) + sizeof(BOOL))) == NULL)
+ if((userdata = (struct userdata_struct *)malloc(size)) == NULL)
{
DEBUG(0,("release_1d_name: malloc fail.\n"));
return;
unbecome_local_master_fail,
userdata);
- free((char *)userdata);
+ zero_free(userdata, size);
}
}
{
struct server_record *servrec;
struct userdata_struct *userdata;
+ int size = sizeof(struct userdata_struct) + sizeof(fstring) + 1;
/* Sanity check. */
if (!lp_local_master())
subrec->work_changed = True;
/* Setup the userdata_struct. */
- if((userdata = (struct userdata_struct *)malloc(sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL)
+ if((userdata = (struct userdata_struct *)malloc(size)) == NULL)
{
DEBUG(0,("become_local_master_browser: malloc fail.\n"));
return;
become_local_master_fail1,
userdata);
- free((char *)userdata);
+ zero_free(userdata, size);
}
/***************************************************************
struct work_record *work;
struct nmb_name nmbname;
struct userdata_struct *userdata;
+ int size = sizeof(struct userdata_struct) + sizeof(fstring)+1;
if (!(work = find_workgroup_on_subnet(subrec, q_name->name))) {
DEBUG(0, ("find_domain_master_name_query_success: failed to find \
/* Setup the userdata_struct - this is copied so we can use
a stack variable for this. */
- if((userdata = (struct userdata_struct *)malloc(sizeof(struct userdata_struct) + sizeof(fstring)+1)) == NULL)
+ if((userdata = (struct userdata_struct *)malloc(size)) == NULL)
{
DEBUG(0, ("find_domain_master_name_query_success: malloc fail.\n"));
return;
domain_master_node_status_fail,
userdata);
- free((char *)userdata);
+ zero_free(userdata, size);
}
/****************************************************************************
if (!success && bcast)
{
if((prdata != rdata) && (prdata != NULL))
- free(rdata);
+ free(prdata);
return; /* Never reply with a negative response to broadcasts. */
}
if(!success && !bcast && nmb->header.nm_flags.recursion_desired)
{
if((prdata != rdata) && (prdata != NULL))
- free(rdata);
+ free(prdata);
return;
}
if(namerec->data.ip != NULL)
free((char *)namerec->data.ip);
+
+ ZERO_STRUCTP(namerec);
free((char *)namerec);
subrec->namelist_changed = True;
if( NULL == namerec->data.ip )
{
DEBUG( 0, ( "add_name_to_subnet: malloc fail when creating ip_flgs.\n" ) );
+
+ ZERO_STRUCTP(namerec);
free( (char *)namerec );
return NULL;
}
if(rrec->userdata)
{
- if(rrec->userdata->free_fn)
- (*rrec->userdata->free_fn)(rrec->userdata);
- else
- free((char *)rrec->userdata);
+ if(rrec->userdata->free_fn) {
+ (*rrec->userdata->free_fn)(rrec->userdata);
+ } else {
+ ZERO_STRUCTP(rrec->userdata);
+ free((char *)rrec->userdata);
+ }
}
/* Ensure we can delete. */
rrec->packet->locked = False;
free_packet(rrec->packet);
+ ZERO_STRUCTP(rrec);
free((char *)rrec);
num_response_packets--; /* count of total number of packets still around */
if((rrec->userdata = (*userdata->copy_fn)(userdata)) == NULL)
{
DEBUG(0,("make_response_queue_record: copy fail for userdata.\n"));
+ ZERO_STRUCTP(rrec);
free(rrec);
return NULL;
}
malloc(sizeof(struct userdata_struct)+userdata->userdata_len)) == NULL)
{
DEBUG(0,("make_response_queue_record: malloc fail for userdata.\n"));
+ ZERO_STRUCTP(rrec);
free(rrec);
return NULL;
}
if (work->serverlist == servrec)
work->serverlist = servrec->next;
+ ZERO_STRUCTP(servrec);
free((char *)servrec);
}
if (work->serverlist == servrec)
work->serverlist = servrec->next;
+ ZERO_STRUCTP(servrec);
free((char *)servrec);
work->subnet->work_changed = True;
}
DEBUG(0,("make_subnet: malloc fail for subnet name !\n"));
close(nmb_sock);
close(dgram_sock);
+ ZERO_STRUCTP(subrec);
free((char *)subrec);
return(NULL);
}
p->locked = False;
free_packet(p);
+ ZERO_STRUCTP(userdata);
free((char *)userdata);
}
if (subrec->workgrouplist == work)
subrec->workgrouplist = work->next;
+ ZERO_STRUCTP(work);
free((char *)work);
}