Skip to content

Commit 92a9d42

Browse files
author
Mikachu2333
committed
修复 xy_str_delete_prefix 误释放的问题
1 parent f5d65e3 commit 92a9d42

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/xy.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,11 @@ xy_str_delete_prefix (const char *str, const char *prefix)
579579
{
580580
char *new = xy_strdup (str);
581581
bool yes = xy_str_start_with (str, prefix);
582-
if (!yes)
583-
return new;
584-
582+
if (!yes) return new;
585583
size_t len = strlen (prefix);
586-
char *cur = new + len;
587-
return cur;
584+
char *ret = xy_strdup (new + len);
585+
free (new);
586+
return ret;
588587
}
589588

590589
/**

0 commit comments

Comments
 (0)