Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
bundle: plug minor memory leak in is_tag_in_date_range()
author
René Scharfe
<l.s.r@web.de>
Fri, 3 Oct 2014 22:40:24 +0000
(
00:40
+0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 7 Oct 2014 17:48:09 +0000
(10:48 -0700)
Free the buffer returned by read_sha1_file() even if no valid tagger
line is found.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
80b616d
)
diff --git
a/bundle.c
b/bundle.c
index b708906cdbd2a14d0e5bcd1e1288c78777cf6a5e..643b8b8b2ea37408be204069affc99a018bfb578 100644
(file)
--- a/
bundle.c
+++ b/
bundle.c
@@
-209,26
+209,29
@@
static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
{
unsigned long size;
enum object_type type;
{
unsigned long size;
enum object_type type;
- char *buf, *line, *lineend;
+ char *buf
= NULL
, *line, *lineend;
unsigned long date;
unsigned long date;
+ int result = 1;
if (revs->max_age == -1 && revs->min_age == -1)
if (revs->max_age == -1 && revs->min_age == -1)
-
return 1
;
+
goto out
;
buf = read_sha1_file(tag->sha1, &type, &size);
if (!buf)
buf = read_sha1_file(tag->sha1, &type, &size);
if (!buf)
-
return 1
;
+
goto out
;
line = memmem(buf, size, "\ntagger ", 8);
if (!line++)
line = memmem(buf, size, "\ntagger ", 8);
if (!line++)
-
return 1
;
+
goto out
;
lineend = memchr(line, '\n', buf + size - line);
line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
if (!line++)
lineend = memchr(line, '\n', buf + size - line);
line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
if (!line++)
-
return 1
;
+
goto out
;
date = strtoul(line, NULL, 10);
date = strtoul(line, NULL, 10);
- free(buf);
- return (revs->max_age == -1 || revs->max_age < date) &&
+ result = (revs->max_age == -1 || revs->max_age < date) &&
(revs->min_age == -1 || revs->min_age > date);
(revs->min_age == -1 || revs->min_age > date);
+out:
+ free(buf);
+ return result;
}
int create_bundle(struct bundle_header *header, const char *path,
}
int create_bundle(struct bundle_header *header, const char *path,