diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-07 16:27:54 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-07 16:27:54 +0900 |
commit | 98c03a0de83f5b5a98ac25d5639f647559c0e619 (patch) | |
tree | c28f2bc0c760defc3fc39f5c6768100072bd2adc /path.c | |
parent | Merge branch 'sb/branch-avoid-repeated-strbuf-release' (diff) | |
parent | sub-process: use child_process.args instead of child_process.argv (diff) | |
download | tgif-98c03a0de83f5b5a98ac25d5639f647559c0e619.tar.xz |
Merge branch 'tg/memfixes'
Fixes for a handful memory access issues identified by valgrind.
* tg/memfixes:
sub-process: use child_process.args instead of child_process.argv
http-push: fix construction of hex value from path
path.c: fix uninitialized memory access
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -34,11 +34,10 @@ static struct strbuf *get_pathname(void) return sb; } -static char *cleanup_path(char *path) +static const char *cleanup_path(const char *path) { /* Clean it up */ - if (!memcmp(path, "./", 2)) { - path += 2; + if (skip_prefix(path, "./", &path)) { while (*path == '/') path++; } @@ -47,7 +46,7 @@ static char *cleanup_path(char *path) static void strbuf_cleanup_path(struct strbuf *sb) { - char *path = cleanup_path(sb->buf); + const char *path = cleanup_path(sb->buf); if (path > sb->buf) strbuf_remove(sb, 0, path - sb->buf); } @@ -64,7 +63,7 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...) strlcpy(buf, bad_path, n); return buf; } - return cleanup_path(buf); + return (char *)cleanup_path(buf); } static int dir_prefix(const char *buf, const char *dir) |