bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: segfault expanding certain arrays created via read -N directly to an


From: Chet Ramey
Subject: Re: segfault expanding certain arrays created via read -N directly to an array.
Date: Mon, 19 Dec 2011 19:59:54 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/19/11 11:12 AM, Dan Douglas wrote:
> Hi, This seems to corrupt the array in a way that crashes when trying to 
> expand the array. Also occurs with the previous patchset.
> 
> ~ $ ( while read -rn 1 'x[y++]'; do :; done < <(printf '%s\n' {0..5}); 
> declare -p x; echo "${x[@]}" )
> declare -a x='([0]="0" [1]="" [2]="1" [3]="" [4]="2" [5]="" [6]="3" [7]="" 
> [8]="4" [9]="" [10]="5" [11]="" [12]="")'
> 0  1  2  3  4  5  
>  ~ $ ( while read -rN 1 'x[y++]'; do :; done < <(printf '%s\n' {0..5}); 
> declare -p x; echo "${x[@]}" )
> declare -a x='([0]="0" [1]= [2]="1" [3]= [4]="2" [5]= [6]="3" [7]= [8]="4" 
> [9]= [10]="5" [11]= [12]="")'
> Segmentation fault

Thanks for the report, and the easy case to reproduce this problem.  Try
the attached patch; it fixes the problem on my system.

Chet


- -- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7v3gIACgkQu1hp8GTqdKsiNwCcD452x4PwKsOQn9sDMGozNTew
JWoAoIuDKHavEWhhEmBhBwCjmiNcOhFo
=mtYW
-----END PGP SIGNATURE-----

Attachment: read-null-string.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]