setup_git_env: use git_pathdup instead of xmalloc + sprintf
[gitweb.git] / builtin / apply.c
index 9c5724eaccfaee62ff10eb097adc39ace351cade..b79691053ff26c853da7884b6d0484285801c6e7 100644 (file)
@@ -1281,9 +1281,7 @@ static int parse_git_header(const char *line, int len, unsigned int size, struct
         */
        patch->def_name = git_header_name(line, len);
        if (patch->def_name && root) {
-               char *s = xmalloc(root_len + strlen(patch->def_name) + 1);
-               strcpy(s, root);
-               strcpy(s + root_len, patch->def_name);
+               char *s = xstrfmt("%s%s", root, patch->def_name);
                free(patch->def_name);
                patch->def_name = s;
        }