summaryrefslogtreecommitdiffstats
path: root/source3/libsmb/nmblib.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-09-17 03:33:37 +0000
committerSimo Sorce <idra@samba.org>2001-09-17 03:33:37 +0000
commitbcbd75f7add425ebee760ddbd2e80a1d4a51e619 (patch)
treeb434877ae75febe93b4a1cb67cd2585d8bfd2a1a /source3/libsmb/nmblib.c
parent484a7c0341fe033fe26fe1e6b597ed1c456c39d4 (diff)
downloadsamba-bcbd75f7add425ebee760ddbd2e80a1d4a51e619.tar.gz
samba-bcbd75f7add425ebee760ddbd2e80a1d4a51e619.tar.xz
samba-bcbd75f7add425ebee760ddbd2e80a1d4a51e619.zip
move to SAFE_FREE()
(This used to be commit 48fc6a6cd52e01b287030fbbf0aa08a6814c5e11)
Diffstat (limited to 'source3/libsmb/nmblib.c')
-rw-r--r--source3/libsmb/nmblib.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 6a24cb382c2..4ecc887524c 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -345,8 +345,7 @@ static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length,
int l = parse_nmb_name(inbuf,*offset,length,&(*recs)[i].rr_name);
(*offset) += l;
if (!l || (*offset)+10 > length) {
- free(*recs);
- *recs = NULL;
+ SAFE_FREE(*recs);
return(False);
}
(*recs)[i].rr_type = RSVAL(inbuf,(*offset));
@@ -356,8 +355,7 @@ static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length,
(*offset) += 10;
if ((*recs)[i].rdlength>sizeof((*recs)[i].rdata) ||
(*offset)+(*recs)[i].rdlength > length) {
- free(*recs);
- *recs = NULL;
+ SAFE_FREE(*recs);
return(False);
}
memcpy((*recs)[i].rdata,inbuf+(*offset),(*recs)[i].rdlength);
@@ -580,19 +578,10 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet)
free_and_exit:
- if(copy_nmb->answers) {
- free((char *)copy_nmb->answers);
- copy_nmb->answers = NULL;
- }
- if(copy_nmb->nsrecs) {
- free((char *)copy_nmb->nsrecs);
- copy_nmb->nsrecs = NULL;
- }
- if(copy_nmb->additional) {
- free((char *)copy_nmb->additional);
- copy_nmb->additional = NULL;
- }
- free((char *)pkt_copy);
+ SAFE_FREE(copy_nmb->answers);
+ SAFE_FREE(copy_nmb->nsrecs);
+ SAFE_FREE(copy_nmb->additional);
+ SAFE_FREE(pkt_copy);
DEBUG(0,("copy_nmb_packet: malloc fail in resource records.\n"));
return NULL;
@@ -640,18 +629,9 @@ struct packet_struct *copy_packet(struct packet_struct *packet)
******************************************************************/
static void free_nmb_packet(struct nmb_packet *nmb)
{
- if (nmb->answers) {
- free(nmb->answers);
- nmb->answers = NULL;
- }
- if (nmb->nsrecs) {
- free(nmb->nsrecs);
- nmb->nsrecs = NULL;
- }
- if (nmb->additional) {
- free(nmb->additional);
- nmb->additional = NULL;
- }
+ SAFE_FREE(nmb->answers);
+ SAFE_FREE(nmb->nsrecs);
+ SAFE_FREE(nmb->additional);
}
/*******************************************************************
@@ -674,7 +654,7 @@ void free_packet(struct packet_struct *packet)
else if (packet->packet_type == DGRAM_PACKET)
free_dgram_packet(&packet->packet.dgram);
ZERO_STRUCTPN(packet);
- free(packet);
+ SAFE_FREE(packet);
}
/*******************************************************************