Use xmemdupz() in many places.
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
39bd2eb56a
commit
182af8343c
@ -441,8 +441,6 @@ static const char *clean_message_id(const char *msg_id)
|
||||
{
|
||||
char ch;
|
||||
const char *a, *z, *m;
|
||||
char *n;
|
||||
size_t len;
|
||||
|
||||
m = msg_id;
|
||||
while ((ch = *m) && (isspace(ch) || (ch == '<')))
|
||||
@ -458,11 +456,7 @@ static const char *clean_message_id(const char *msg_id)
|
||||
die("insane in-reply-to: %s", msg_id);
|
||||
if (++z == m)
|
||||
return a;
|
||||
len = z - a;
|
||||
n = xmalloc(len + 1);
|
||||
memcpy(n, a, len);
|
||||
n[len] = 0;
|
||||
return n;
|
||||
return xmemdupz(a, z - a);
|
||||
}
|
||||
|
||||
int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
@ -541,9 +535,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
endpos = strchr(committer, '>');
|
||||
if (!endpos)
|
||||
die("bogos committer info %s\n", committer);
|
||||
add_signoff = xmalloc(endpos - committer + 2);
|
||||
memcpy(add_signoff, committer, endpos - committer + 1);
|
||||
add_signoff[endpos - committer + 1] = 0;
|
||||
add_signoff = xmemdupz(committer, endpos - committer + 1);
|
||||
}
|
||||
else if (!strcmp(argv[i], "--attach")) {
|
||||
rev.mime_boundary = git_version_string;
|
||||
|
Reference in New Issue
Block a user