summaryrefslogtreecommitdiff
path: root/urlmatch.c
diff options
context:
space:
mode:
authorThomas Rast <trast@inf.ethz.ch>2013-09-12 07:15:40 -0700
committerJunio C Hamano <gitster@pobox.com>2013-09-12 15:27:01 -0700
commita7f0a0efa5aa2459e284a2aa5a217324bf9d3875 (patch)
tree9e9ae52ffee3d4810b9fc4330c9eb9f6345ba013 /urlmatch.c
parent6667a6ac20747eb56eb2c03c39aceaf6aebbae3c (diff)
downloadgit-a7f0a0efa5aa2459e284a2aa5a217324bf9d3875.tar.gz
urlmatch.c: recompute pointer after append_normalized_escapesjc/url-match
When append_normalized_escapes is called, its internal strbuf_add* calls can cause the strbuf's buf to be reallocated changing the value of the buf pointer. Do not use the strbuf buf pointer from before any append_normalized_escapes calls afterwards. Instead recompute the needed pointer. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Kyle J. McKay <mackyle@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'urlmatch.c')
-rw-r--r--urlmatch.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/urlmatch.c b/urlmatch.c
index 1db76c89bc..ec87cba750 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -281,9 +281,11 @@ char *url_normalize(const char *url, struct url_info *out_info)
url_len--;
}
for (;;) {
- const char *seg_start = norm.buf + norm.len;
+ const char *seg_start;
+ size_t seg_start_off = norm.len;
const char *next_slash = url + strcspn(url, "/?#");
int skip_add_slash = 0;
+
/*
* RFC 3689 indicates that any . or .. segments should be
* unescaped before being checked for.
@@ -297,6 +299,8 @@ char *url_normalize(const char *url, struct url_info *out_info)
strbuf_release(&norm);
return NULL;
}
+
+ seg_start = norm.buf + seg_start_off;
if (!strcmp(seg_start, ".")) {
/* ignore a . segment; be careful not to remove initial '/' */
if (seg_start == path_start + 1) {