Skip to content

Commit 520b7fd

Browse files
author
Mikachu2333
committed
修复 xy_normalize_path 内存泄露
1 parent 5ab8dec commit 520b7fd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/xy.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,13 +1241,14 @@ xy_normalize_path (const char *path)
12411241

12421242
if (xy_str_start_with (new, "~"))
12431243
{
1244-
new = xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~"));
1244+
xy_str_swap (&new, xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~")));
12451245
}
12461246

12471247
if (xy.on_windows)
1248-
return xy_str_gsub (new, "/", "\\");
1249-
else
1250-
return new;
1248+
{
1249+
xy_str_swap (&new, xy_str_gsub (new, "/", "\\"));
1250+
}
1251+
return new;
12511252
}
12521253

12531254

0 commit comments

Comments
 (0)