]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diffcore-rename.c
diffcore-rename: move old_dir/new_dir definition to plug leak
[thirdparty/git.git] / diffcore-rename.c
index 4ef0459cfb500049154ad72270e5ec5368702cf4..15b4add5563bd6a2e9ef716c21bad38785a37364 100644 (file)
@@ -448,9 +448,9 @@ static void update_dir_rename_counts(struct dir_rename_info *info,
                                     const char *oldname,
                                     const char *newname)
 {
-       char *old_dir = xstrdup(oldname);
-       char *new_dir = xstrdup(newname);
-       char new_dir_first_char = new_dir[0];
+       char *old_dir;
+       char *new_dir;
+       const char new_dir_first_char = newname[0];
        int first_time_in_loop = 1;
 
        if (!info->setup)
@@ -475,6 +475,10 @@ static void update_dir_rename_counts(struct dir_rename_info *info,
                 */
                return;
 
+
+       old_dir = xstrdup(oldname);
+       new_dir = xstrdup(newname);
+
        while (1) {
                int drd_flag = NOT_RELEVANT;