diff options
author | Jeremy Allison <jra@samba.org> | 2000-12-15 21:29:06 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-12-15 21:29:06 +0000 |
commit | 506b5e34c3ba16768dbc82ba21044787de160c45 (patch) | |
tree | 72a08329443f68c96dfc45dbfd47c670139d654b /source/rpc_parse | |
parent | 69fe739303b105f2c488f266f13977da1b6b201d (diff) | |
download | samba-506b5e34c3ba16768dbc82ba21044787de160c45.tar.gz samba-506b5e34c3ba16768dbc82ba21044787de160c45.tar.xz samba-506b5e34c3ba16768dbc82ba21044787de160c45.zip |
Added lock backouts on fail.
When chaining together long lines of bloody "if" statements, which should
logically be separated, and one of them allocates memory, remember to
*free* it *WHETHER OR NOT THE IF STATEMENTS SUCCEEDED* !!!!
Yes I do consider this a bug in the coding style of Tridge, Rusty, Tim et al. :-).
I'm just pissed 'cos this took 4 hours to track down even with an insure error report
stating me in the face and also Ben Woodward looking over the code with me :-).
Jeremy.
Diffstat (limited to 'source/rpc_parse')
-rw-r--r-- | source/rpc_parse/parse_srv.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/source/rpc_parse/parse_srv.c b/source/rpc_parse/parse_srv.c index be7401ffc5f..69cc1e7bda2 100644 --- a/source/rpc_parse/parse_srv.c +++ b/source/rpc_parse/parse_srv.c @@ -291,7 +291,7 @@ static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct int i; if (UNMARSHALLING(ps)) { - if (!(info1 = malloc(num_entries * sizeof(SRV_SHARE_INFO_1)))) + if (!(info1 = prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1)))) return False; memset(info1, '\0', num_entries * sizeof(SRV_SHARE_INFO_1)); ctr->share.info1 = info1; @@ -317,7 +317,7 @@ static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct int i; if (UNMARSHALLING(ps)) { - if (!(info2 = malloc(num_entries * sizeof(SRV_SHARE_INFO_2)))) + if (!(info2 = prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2)))) return False; memset(info2, '\0', num_entries * sizeof(SRV_SHARE_INFO_2)); ctr->share.info2 = info2; @@ -346,43 +346,6 @@ static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct } /******************************************************************* - Frees a SRV_SHARE_INFO_CTR structure. -********************************************************************/ - -void free_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr) -{ - if(!ctr) - return; - if(ctr->share.info) - free(ctr->share.info); - memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR)); -} - -/******************************************************************* - Frees a SRV_Q_NET_SHARE_ENUM structure. -********************************************************************/ - -void free_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n) -{ - if(!q_n) - return; - free_srv_share_info_ctr(&q_n->ctr); - memset(q_n, '\0', sizeof(SRV_Q_NET_SHARE_ENUM)); -} - -/******************************************************************* - Frees a SRV_R_NET_SHARE_ENUM structure. -********************************************************************/ - -void free_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n) -{ - if(!r_n) - return; - free_srv_share_info_ctr(&r_n->ctr); - memset(r_n, '\0', sizeof(SRV_R_NET_SHARE_ENUM)); -} - -/******************************************************************* Inits a SRV_Q_NET_SHARE_ENUM structure. ********************************************************************/ |