mirror of
https://github.com/irssi/irssi.git
synced 2026-08-22 18:12:12 +02:00
Fix escape_string returning wrong address
escape_string should return the alloc'ed address, not a pointer to the
NUL at the end of the string
This fixes dc99f8d7a of PR #658 (LemonBoy/dcc-autoaccept)
This commit is contained in:
parent
29f27cfb39
commit
01adadf8a9
1 changed files with 6 additions and 5 deletions
|
|
@ -728,16 +728,17 @@ int expand_escape(const char **data)
|
||||||
char *escape_string(const char *str, const char *what)
|
char *escape_string(const char *str, const char *what)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
char *ret;
|
char *ret, *escaped;
|
||||||
|
|
||||||
ret = g_malloc(strlen(str) * 2 + 1);
|
ret = g_malloc(strlen(str) * 2 + 1);
|
||||||
for (p = str; *p != '\0'; p++, ret++) {
|
escaped = ret;
|
||||||
|
for (p = str; *p != '\0'; p++, escaped++) {
|
||||||
if (strchr(what, *p) != NULL) {
|
if (strchr(what, *p) != NULL) {
|
||||||
*ret++ = '\\';
|
*escaped++ = '\\';
|
||||||
}
|
}
|
||||||
*ret = *p;
|
*escaped = *p;
|
||||||
}
|
}
|
||||||
*ret = '\0';
|
*escaped = '\0';
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue