summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-08-05 10:10:16 +0000
committerSimo Sorce <idra@samba.org>2001-08-05 10:10:16 +0000
commite485a1a4986c9328754b9a8b3054b8a6738b54f0 (patch)
treee769aabf19f50ce524b26584b1de5dee00a6ae7d /source3/lib
parentefe1d83dbbe8492f0077b2c354eb087e53e42cd7 (diff)
downloadsamba-e485a1a4986c9328754b9a8b3054b8a6738b54f0.tar.gz
samba-e485a1a4986c9328754b9a8b3054b8a6738b54f0.tar.bz2
samba-e485a1a4986c9328754b9a8b3054b8a6738b54f0.zip
Some fixes about malloc/Realloc and mem leak
thanks to andreas moroder (This used to be commit b29a549cdd85d42a1697041ab04f0ae4eddd23ca)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/messages.c15
-rw-r--r--source3/lib/util.c2
-rw-r--r--source3/lib/util_file.c4
3 files changed, 15 insertions, 6 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 78cd3e22bc..54f6321041 100644
--- a/source3/lib/messages.c
+++ b/source3/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/source3/lib/util.c b/source3/lib/util.c
index 282e0e43fa..86c93e5ad0 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -524,7 +524,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(buf,size+8);
if (!buf) size /= 2;
}
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 01a8b1c333..a92eb15333 100644
--- a/source3/lib/util_file.c
+++ b/source3/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;