Re: [PATCH] git-archive: convert archive entries like checkouts do

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

 



On Sat, 19 May 2007, René Scharfe wrote:

> diff --git a/archive-tar.c b/archive-tar.c
> index 56ff356..eb0abc7 100644
> --- a/archive-tar.c
> +++ b/archive-tar.c
> @@ -83,11 +83,12 @@ static void strbuf_append_string(struct strbuf *sb, const char *s)
>  	int slen = strlen(s);
>  	int total = sb->len + slen;
>  	if (total > sb->alloc) {
> -		sb->buf = xrealloc(sb->buf, total);
> -		sb->alloc = total;
> +		sb->buf = xrealloc(sb->buf, total + 1);
> +		sb->alloc = total + 1;

Conditional needs a "+ 1", too.

>  	}
>  	memcpy(sb->buf + sb->len, s, slen);
>  	sb->len = total;
> +	sb->buf[total] = '\0';
>  }
>  
>  /*
> @@ -272,18 +273,19 @@ static int write_tar_entry(const unsigned char *sha1,
>  	}
>  	if (path.alloc < baselen + filenamelen) {
>  		free(path.buf);
> -		path.buf = xmalloc(baselen + filenamelen);
> -		path.alloc = baselen + filenamelen;
> +		path.buf = xmalloc(baselen + filenamelen + 1);
> +		path.alloc = baselen + filenamelen + 1;

Same here.

	-Daniel
*This .sig left intentionally blank*

[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