diff options
author | Simo Sorce <idra@samba.org> | 2001-08-05 16:26:24 +0000 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2001-08-05 16:26:24 +0000 |
commit | beb48eb9514b7777a80bc49cba539051c838657a (patch) | |
tree | fdc27014a41ce5bd70dad8b1655f72c9d72c771c | |
parent | bcc89b048de25f8839f8817d06723c1d63462242 (diff) | |
download | samba-beb48eb9514b7777a80bc49cba539051c838657a.tar.gz samba-beb48eb9514b7777a80bc49cba539051c838657a.tar.xz samba-beb48eb9514b7777a80bc49cba539051c838657a.zip |
Some fixes about malloc/Realloc and mem leak
thanks to andreas moroder
(this builds ok)
-rw-r--r-- | source/lib/messages.c | 15 | ||||
-rw-r--r-- | source/lib/util.c | 2 | ||||
-rw-r--r-- | source/lib/util_file.c | 4 |
3 files changed, 15 insertions, 6 deletions
diff --git a/source/lib/messages.c b/source/lib/messages.c index 4813c14f132..be2cc6e95cf 100644 --- a/source/lib/messages.c +++ b/source/lib/messages.c @@ -322,12 +322,19 @@ void message_register(int msg_type, dfn = (struct dispatch_fns *)malloc(sizeof(*dfn)); - ZERO_STRUCTP(dfn); + if (dfn != NULL) { - dfn->msg_type = msg_type; - dfn->fn = fn; + ZERO_STRUCTPN(dfn); - DLIST_ADD(dispatch_fns, dfn); + dfn->msg_type = msg_type; + dfn->fn = fn; + + DLIST_ADD(dispatch_fns, dfn); + } + else { + + DEBUG(0,("message_register: Not enough memory. malloc failed!\n")); + } } /**************************************************************************** diff --git a/source/lib/util.c b/source/lib/util.c index 2fa680898ae..fd1299701e7 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -539,7 +539,7 @@ SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen, } while (!buf && size>0) { - buf = (char *)Realloc(buf,size+8); + buf = (char *)malloc(size+8); if (!buf) size /= 2; } diff --git a/source/lib/util_file.c b/source/lib/util_file.c index 4e2adc97bcc..2517e26ed45 100644 --- a/source/lib/util_file.c +++ b/source/lib/util_file.c @@ -282,13 +282,15 @@ char *fgets_slash(char *s2,int maxlen,FILE *f) if (feof(f)) return(NULL); + if (maxlen <2) return(NULL); + if (!s2) { maxlen = MIN(maxlen,8); s = (char *)Realloc(s,maxlen); } - if (!s || maxlen < 2) return(NULL); + if (!s) return(NULL); *s = 0; |