Skip to content

Commit 897bc91

Browse files
author
Mikachu2333
committed
修复 xy_normalize_path 内存泄漏问题
1 parent 1509bab commit 897bc91

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/xy.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,10 @@ xy_normalize_path (const char *path)
12421242

12431243
if (xy_str_start_with (new, "~"))
12441244
{
1245-
xy_str_swap (&new, xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~")));
1245+
char *tmp = xy_str_delete_prefix (new, "~");
1246+
char *joined = xy_2strcat (xy_os_home, tmp);
1247+
free (tmp);
1248+
xy_str_swap (&new, joined);
12461249
}
12471250

12481251
if (xy.on_windows)

0 commit comments

Comments
 (0)