1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Some fixes about malloc/Realloc and mem leak

thanks to andreas moroder
This commit is contained in:
Simo Sorce 0001-01-01 00:00:00 +00:00
parent b4f06c3ecf
commit b29a549cdd
3 changed files with 15 additions and 6 deletions

View File

@ -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"));
}
}
/****************************************************************************

View File

@ -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;
}

View File

@ -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;