urlmatch.c: recompute pointer after append_normalized_escapes
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>
Thomas Rast committed
Sep 12, 2013 at 07:15 UTC
a7f0a0efa5aa2459e284a2aa5a217324bf9d3875
1 file changed
+5
-1
urlmatch.c
+5
-1
@@ -281,9 +281,11 @@ char *url_normalize(const char *url, struct url_info *out_info)
281
url_len--;
282
}
283
for (;;) {
284
- const char *seg_start = norm.buf + norm.len;
284
+ const char *seg_start;
285
+ size_t seg_start_off = norm.len;
286
const char *next_slash = url + strcspn(url, "/?#");
287
int skip_add_slash = 0;
288
+
289
/*
290
* RFC 3689 indicates that any . or .. segments should be
291
* unescaped before being checked for.
@@ -297,6 +299,8 @@ char *url_normalize(const char *url, struct url_info *out_info)
299
strbuf_release(&norm);
300
return NULL;
301
}
302
+
303
+ seg_start = norm.buf + seg_start_off;
304
if (!strcmp(seg_start, ".")) {
305
/* ignore a . segment; be careful not to remove initial '/' */
306
if (seg_start == path_start + 1) {