Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: crash/memory corruption when completing dynamic named directory
- X-seq: zsh-workers 28941
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: crash/memory corruption when completing dynamic named directory
- Date: Sun, 27 Mar 2011 13:37:01 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=s5jycFar0XQ0i305ewKSUytORDDbNxDbBHU1YmZ2tG0=; b=uRMD61brWTL7SLZ5+lJnmGqkiTOLK6C8sKZUjBr0sQDnvSrWcZ7sk0Quo7tkIBNoiB /Nblhq7FvckPHyx7IU5KlzYRWiw5QwN0q3kzAuQzF5b8zUgnS96CEIPF6PzoC4w3E8dU UF7mrUDxmybh8JkP3iAwqu87fsBokNNu0mM8w=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=m8W7yzWfI6rZ+cWGJli3Z1B4Lvj+0WggJpkWHXbyhpINZSBIjxQJhgYAQf3nps6WWA BU52f9y2uyf2t+oK3GFIg9pDOFJ/BcDRRXv0sAOUJC23QbvWM+JbxASNC4n9p3gm8tuR RkyCIC2uYlH+1UUpJ/5gdEySSQi+5NycBy9RI=
- In-reply-to: <AANLkTinOF8x4XY8dtiPUkN=MaAcnyN59a_9yujM5KQAo@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AANLkTi=qwPYqiwCGVw=vkN75JUFntDDrLgiO-CjYQQH9@mail.gmail.com> <AANLkTi=DsVZv5J2m26e86XgaD3qJtRtWMfDdWEoh3baD@mail.gmail.com> <alpine.LNX.2.01.1103261818320.22141@hp> <AANLkTinOF8x4XY8dtiPUkN=MaAcnyN59a_9yujM5KQAo@mail.gmail.com>
On 27 March 2011 13:32, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> 2011/3/26 Benjamin R. Haskell <zsh@xxxxxxxxxx>:
>> On Sat, 26 Mar 2011, Johan Sundström wrote:
>>
>>> On Sat, Mar 26, 2011 at 05:54, Mikael Magnusson wrote:
>>>
>>>> I can't reproduce this in zsh -f yet, all that happens is that the
>>>> completion just fails quietly without doing anything.
>>>> % echo ネネネネネ ~[<tab>
>>>> results in
>>>> % echo <e3><ad><e3><ad><e3><ad><e3><ad><e3><ad> ~[
>>>>
>>>> any idea what could be wrong or what I can try to narrow it down?
>>
>> The problem is that the string of 'ne's is being unmetafy'ed when it
>> shouldn't be. I don't know where. But that's what's happening.
>
> calling stringaszleline with zlemetaline only occurs in one other
> place: unmetafy_line :).
>
> pws, afaict, only the first little bit of zlemetaline is needed for
> this, ie the outcs calculation. Would it be okay to split this out to
> a separate function and call that from get_cursor and stringaszleline?
> Otherwise we have to copy zlemetaline first and then run
> stringaszleline, and discard all that work, which seems silly. Or does
> outcs actually depend on the conversion too? There's a comment that
> suggests it doesn't, but there are some assignments to it further
> down.
Here's a patch for copying the string and doing all the work, which
I've confirmed fixes the issue.
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 98091b2..2c35874 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -233,8 +233,10 @@ get_cursor(UNUSED(Param pm))
/* A lot of work for one number, but still... */
ZLE_STRING_T tmpline;
int tmpcs, tmpll, tmpsz;
- tmpline = stringaszleline(zlemetaline, zlemetacs,
+ char *tmpmetaline = ztrdup(zlemetaline);
+ tmpline = stringaszleline(tmpmetaline, zlemetacs,
&tmpll, &tmpsz, &tmpcs);
+ free(tmpmetaline);
free(tmpline);
return tmpcs;
}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author