Skip to content

Commit 98c03a0

Browse files
committed
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
2 parents cfa0fd0 + 2944a94 commit 98c03a0

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ static int get_oid_hex_from_objpath(const char *path, struct object_id *oid)
10181018
memcpy(hex, path, 2);
10191019
path += 2;
10201020
path++; /* skip '/' */
1021-
memcpy(hex, path, GIT_SHA1_HEXSZ - 2);
1021+
memcpy(hex + 2, path, GIT_SHA1_HEXSZ - 2);
10221022

10231023
return get_oid_hex(hex, oid);
10241024
}

path.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ static struct strbuf *get_pathname(void)
3434
return sb;
3535
}
3636

37-
static char *cleanup_path(char *path)
37+
static const char *cleanup_path(const char *path)
3838
{
3939
/* Clean it up */
40-
if (!memcmp(path, "./", 2)) {
41-
path += 2;
40+
if (skip_prefix(path, "./", &path)) {
4241
while (*path == '/')
4342
path++;
4443
}
@@ -47,7 +46,7 @@ static char *cleanup_path(char *path)
4746

4847
static void strbuf_cleanup_path(struct strbuf *sb)
4948
{
50-
char *path = cleanup_path(sb->buf);
49+
const char *path = cleanup_path(sb->buf);
5150
if (path > sb->buf)
5251
strbuf_remove(sb, 0, path - sb->buf);
5352
}
@@ -64,7 +63,7 @@ char *mksnpath(char *buf, size_t n, const char *fmt, ...)
6463
strlcpy(buf, bad_path, n);
6564
return buf;
6665
}
67-
return cleanup_path(buf);
66+
return (char *)cleanup_path(buf);
6867
}
6968

7069
static int dir_prefix(const char *buf, const char *dir)

sub-process.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, co
7777
{
7878
int err;
7979
struct child_process *process;
80-
const char *argv[] = { cmd, NULL };
8180

8281
entry->cmd = cmd;
8382
process = &entry->process;
8483

8584
child_process_init(process);
86-
process->argv = argv;
85+
argv_array_push(&process->args, cmd);
8786
process->use_shell = 1;
8887
process->in = -1;
8988
process->out = -1;

0 commit comments

Comments
 (0)