mirror of
https://github.com/RubyMetric/chsrc
synced 2026-01-12 07:19:01 +08:00
修复 xy_str_delete_prefix 误释放的问题
This commit is contained in:
9
lib/xy.h
9
lib/xy.h
@@ -583,12 +583,11 @@ xy_str_delete_prefix (const char *str, const char *prefix)
|
|||||||
{
|
{
|
||||||
char *new = xy_strdup (str);
|
char *new = xy_strdup (str);
|
||||||
bool yes = xy_str_start_with (str, prefix);
|
bool yes = xy_str_start_with (str, prefix);
|
||||||
if (!yes)
|
if (!yes) return new;
|
||||||
return new;
|
|
||||||
|
|
||||||
size_t len = strlen (prefix);
|
size_t len = strlen (prefix);
|
||||||
char *cur = new + len;
|
char *ret = xy_strdup (new + len);
|
||||||
return cur;
|
free (new);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user