Skip to content

Commit 948d551

Browse files
author
Mikachu2333
committed
修复 xy_normalize_path 内存泄漏问题
1 parent 41783b8 commit 948d551

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
@@ -1250,7 +1250,10 @@ xy_normalize_path (const char *path)
12501250

12511251
if (xy_str_start_with (new, "~"))
12521252
{
1253-
xy_str_swap (&new, xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~")));
1253+
char *tmp = xy_str_delete_prefix (new, "~");
1254+
char *joined = xy_2strcat (xy_os_home, tmp);
1255+
free (tmp);
1256+
xy_str_swap (&new, joined);
12541257
}
12551258

12561259
if (xy.on_windows)

0 commit comments

Comments
 (0)