git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] http-push: update memory allocation for http headers
@ 2009-01-18 13:16 Ray Chuan
  2009-01-18 14:20 ` Mike Hommey
  2009-01-18 14:55 ` Johannes Schindelin
  0 siblings, 2 replies; 3+ messages in thread
From: Ray Chuan @ 2009-01-18 13:16 UTC (permalink / raw)
  To: git

In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the
header strings were with the removal "opaquelocktoken:" (16
characters).

Unfortunately, this was without the corresponding change in memory
allocation. In this patch we update these allocations.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http-push.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/http-push.c b/http-push.c
index a4b7d08..a6522dd 100644
--- a/http-push.c
+++ b/http-push.c
@@ -595,7 +595,7 @@ static int refresh_lock(struct remote_lock *lock)

 	lock->refreshing = 1;

-	if_header = xmalloc(strlen(lock->token) + 25);
+	if_header = xmalloc(strlen(lock->token) + 9);
 	sprintf(if_header, "If: (<%s>)", lock->token);
 	sprintf(timeout_header, "Timeout: Second-%ld", lock->timeout);
 	dav_headers = curl_slist_append(dav_headers, if_header);
@@ -1306,7 +1306,7 @@ static int unlock_remote(struct remote_lock *lock)
 	struct curl_slist *dav_headers = NULL;
 	int rc = 0;

-	lock_token_header = xmalloc(strlen(lock->token) + 31);
+	lock_token_header = xmalloc(strlen(lock->token) + 15);
 	sprintf(lock_token_header, "Lock-Token: <%s>",
 		lock->token);
 	dav_headers = curl_slist_append(dav_headers, lock_token_header);
@@ -1730,7 +1730,7 @@ static int update_remote(unsigned char *sha1,
struct remote_lock *lock)
 	struct buffer out_buffer = { STRBUF_INIT, 0 };
 	struct curl_slist *dav_headers = NULL;

-	if_header = xmalloc(strlen(lock->token) + 25);
+	if_header = xmalloc(strlen(lock->token) + 9);
 	sprintf(if_header, "If: (<%s>)", lock->token);
 	dav_headers = curl_slist_append(dav_headers, if_header);

@@ -1949,7 +1949,7 @@ static void update_remote_info_refs(struct
remote_lock *lock)
 	remote_ls("refs/", (PROCESS_FILES | RECURSIVE),
 		  add_remote_info_ref, &buffer.buf);
 	if (!aborted) {
-		if_header = xmalloc(strlen(lock->token) + 25);
+		if_header = xmalloc(strlen(lock->token) + 9);
 		sprintf(if_header, "If: (<%s>)", lock->token);
 		dav_headers = curl_slist_append(dav_headers, if_header);

-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] http-push: update memory allocation for http headers
  2009-01-18 13:16 [PATCH] http-push: update memory allocation for http headers Ray Chuan
@ 2009-01-18 14:20 ` Mike Hommey
  2009-01-18 14:55 ` Johannes Schindelin
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Hommey @ 2009-01-18 14:20 UTC (permalink / raw)
  To: Ray Chuan; +Cc: git

On Sun, Jan 18, 2009 at 09:16:04PM +0800, Ray Chuan wrote:
> In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the
> header strings were with the removal "opaquelocktoken:" (16
> characters).
> 
> Unfortunately, this was without the corresponding change in memory
> allocation. In this patch we update these allocations.
> 
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
> ---

It would be better to just turn the whole thing to use strbuf, and/or
extend the patch set I sent earlier today to handle webdav.

Mike

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] http-push: update memory allocation for http headers
  2009-01-18 13:16 [PATCH] http-push: update memory allocation for http headers Ray Chuan
  2009-01-18 14:20 ` Mike Hommey
@ 2009-01-18 14:55 ` Johannes Schindelin
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2009-01-18 14:55 UTC (permalink / raw)
  To: Ray Chuan; +Cc: git

Hi,

On Sun, 18 Jan 2009, Ray Chuan wrote:

> In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the
> header strings were with the removal "opaquelocktoken:" (16
> characters).
> 
> Unfortunately, this was without the corresponding change in memory
> allocation. In this patch we update these allocations.

Rather than doing this (which will result in as error-prone code), why 
don't you replace those things by strbufs?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-18 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-18 13:16 [PATCH] http-push: update memory allocation for http headers Ray Chuan
2009-01-18 14:20 ` Mike Hommey
2009-01-18 14:55 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).