Re: [PATCH 2/2] Use xmemdup in many places.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 19, 2007 at 08:08:12AM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@xxxxxxxxxx> writes:
> 
> > Signed-off-by: Pierre Habouzit <madcoder@xxxxxxxxxx>
> > ---
> >  attr.c                  |    7 +------
> >  builtin-add.c           |    8 ++------
> >  builtin-apply.c         |   11 ++---------
> >  builtin-fetch--tool.c   |    6 +-----
> >  builtin-fmt-merge-msg.c |   17 ++++++-----------
> >  builtin-for-each-ref.c  |   40 +++++++++-------------------------------
> >  builtin-log.c           |   12 ++----------
> >  builtin-ls-files.c      |    9 +--------
> >  builtin-mv.c            |    5 +----
> >  builtin-revert.c        |    4 +---
> >  builtin-shortlog.c      |   11 ++---------
> >  commit.c                |   16 ++++++----------
> >  connect.c               |    4 +---
> >  convert.c               |    7 +------
> >  diff.c                  |   13 ++-----------
> >  diffcore-order.c        |    7 ++-----
> >  fast-import.c           |    4 +---
> >  http-push.c             |    9 ++-------
> >  imap-send.c             |   20 +++++---------------
> >  merge-recursive.c       |   19 ++++---------------
> >  refs.c                  |   12 ++++--------
> >  sha1_file.c             |   12 +++---------
> >  tag.c                   |    4 +---
> >  23 files changed, 60 insertions(+), 197 deletions(-)
> > ...
> > diff --git a/builtin-apply.c b/builtin-apply.c
> > index 05011bb..900d0a7 100644
> > --- a/builtin-apply.c
> > +++ b/builtin-apply.c
> > @@ -293,11 +293,7 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
> >  			return def;
> >  	}
> >  
> > -	name = xmalloc(len + 1);
> > -	memcpy(name, start, len);
> > -	name[len] = 0;
> > -	free(def);
> > -	return name;
> > +	return xmemdup(start, len);
> >  }
> 
> Did we start leaking "def" here? 

  Hmm I fear we are. that has to be fixed indeed.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@xxxxxxxxxx
OOO                                                http://www.madism.org

Attachment: pgpprpnFMZjLR.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux